omnikey-cli 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -47,13 +47,15 @@ program
47
47
  .command('status')
48
48
  .description('Show status of Omnikey daemon (lsof on configured port)')
49
49
  .action(status_1.statusCmd);
50
- program.parseAsync(process.argv);
51
50
  // Add logs command
52
51
  program
53
52
  .command('logs')
54
53
  .description('Show logs of the running Omnikey daemon')
55
54
  .option('--lines <lines>', 'Number of log lines to show', '50')
55
+ .option('--errors', 'Show only error logs')
56
56
  .action((options) => {
57
57
  const lines = Number(options.lines) || 50;
58
- (0, showLogs_1.showLogs)(lines);
58
+ const errorsOnly = !!options.errors;
59
+ (0, showLogs_1.showLogs)(lines, errorsOnly);
59
60
  });
61
+ program.parseAsync(process.argv);
package/dist/showLogs.js CHANGED
@@ -9,40 +9,24 @@ const path_1 = __importDefault(require("path"));
9
9
  /**
10
10
  * Show the logs of the running Omnikey daemon by printing the contents of the daemon log file.
11
11
  * Prints the last N lines (default 50) for convenience.
12
+ * If errorsOnly is true, shows daemon-error.log instead.
12
13
  */
13
- function showLogs(lines = 50) {
14
+ function showLogs(lines = 50, errorsOnly = false) {
14
15
  const homeDir = process.env.HOME || process.env.USERPROFILE || '.';
15
16
  const configDir = path_1.default.join(homeDir, '.omnikey');
16
- const logPath = path_1.default.join(configDir, 'daemon.log');
17
- const errorLogPath = path_1.default.join(configDir, 'daemon-error.log');
18
- let logLines = [];
19
- let errorLines = [];
20
- if (fs_1.default.existsSync(logPath)) {
21
- const logContent = fs_1.default.readFileSync(logPath, 'utf-8');
22
- logLines = logContent.split('\n');
23
- }
24
- if (fs_1.default.existsSync(errorLogPath)) {
25
- const errorContent = fs_1.default.readFileSync(errorLogPath, 'utf-8');
26
- errorLines = errorContent.split('\n');
27
- }
28
- if (logLines.length === 0 && errorLines.length === 0) {
29
- console.log('No daemon.log or daemon-error.log file found.');
17
+ const logPath = path_1.default.join(configDir, errorsOnly ? 'daemon-error.log' : 'daemon.log');
18
+ if (!fs_1.default.existsSync(logPath)) {
19
+ console.log(errorsOnly ? 'No error logs found.' : 'No daemon logs found.');
30
20
  return;
31
21
  }
32
- const left = logLines.slice(-lines);
33
- const right = errorLines.slice(-lines);
34
- // Calculate column widths
35
- const leftWidth = Math.max(40, ...left.map((l) => l.length));
36
- const rightWidth = Math.max(40, ...right.map((l) => l.length));
37
- // Print header
38
- const leftHeader = 'Other Logs'.padEnd(leftWidth);
39
- const rightHeader = 'Errors'.padEnd(rightWidth);
40
- console.log(`${leftHeader} | ${rightHeader}`);
41
- console.log('-'.repeat(leftWidth) + '-+-' + '-'.repeat(rightWidth));
42
- // Print lines side by side
43
- for (let i = 0; i < lines; i++) {
44
- const l = left[i] !== undefined ? left[i] : '';
45
- const r = right[i] !== undefined ? right[i] : '';
46
- console.log(l.padEnd(leftWidth) + ' | ' + r.padEnd(rightWidth));
22
+ const logContent = fs_1.default.readFileSync(logPath, 'utf-8');
23
+ const logLines = logContent.split('\n');
24
+ const lastLines = logLines.slice(-lines);
25
+ if (errorsOnly) {
26
+ console.log('--- Error Logs ---');
27
+ }
28
+ else {
29
+ console.log('--- Daemon Logs ---');
47
30
  }
31
+ lastLines.forEach((line) => console.log(line));
48
32
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
7
- "version": "1.0.8",
7
+ "version": "1.0.10",
8
8
  "description": "CLI for onboarding users to Omnikey AI and configuring OPENAI_API_KEY. Use Yarn for install/build.",
9
9
  "engines": {
10
10
  "node": ">=14.0.0",
package/src/index.ts CHANGED
@@ -56,14 +56,16 @@ program
56
56
  .description('Show status of Omnikey daemon (lsof on configured port)')
57
57
  .action(statusCmd);
58
58
 
59
- program.parseAsync(process.argv);
60
-
61
59
  // Add logs command
62
60
  program
63
61
  .command('logs')
64
62
  .description('Show logs of the running Omnikey daemon')
65
63
  .option('--lines <lines>', 'Number of log lines to show', '50')
64
+ .option('--errors', 'Show only error logs')
66
65
  .action((options) => {
67
66
  const lines = Number(options.lines) || 50;
68
- showLogs(lines);
67
+ const errorsOnly = !!options.errors;
68
+ showLogs(lines, errorsOnly);
69
69
  });
70
+
71
+ program.parseAsync(process.argv);
package/src/showLogs.ts CHANGED
@@ -4,46 +4,25 @@ import path from 'path';
4
4
  /**
5
5
  * Show the logs of the running Omnikey daemon by printing the contents of the daemon log file.
6
6
  * Prints the last N lines (default 50) for convenience.
7
+ * If errorsOnly is true, shows daemon-error.log instead.
7
8
  */
8
- export function showLogs(lines: number = 50) {
9
+ export function showLogs(lines: number = 50, errorsOnly: boolean = false) {
9
10
  const homeDir = process.env.HOME || process.env.USERPROFILE || '.';
10
11
  const configDir = path.join(homeDir, '.omnikey');
11
- const logPath = path.join(configDir, 'daemon.log');
12
- const errorLogPath = path.join(configDir, 'daemon-error.log');
12
+ const logPath = path.join(configDir, errorsOnly ? 'daemon-error.log' : 'daemon.log');
13
13
 
14
- let logLines: string[] = [];
15
- let errorLines: string[] = [];
16
- if (fs.existsSync(logPath)) {
17
- const logContent = fs.readFileSync(logPath, 'utf-8');
18
- logLines = logContent.split('\n');
19
- }
20
- if (fs.existsSync(errorLogPath)) {
21
- const errorContent = fs.readFileSync(errorLogPath, 'utf-8');
22
- errorLines = errorContent.split('\n');
23
- }
24
-
25
- if (logLines.length === 0 && errorLines.length === 0) {
26
- console.log('No daemon.log or daemon-error.log file found.');
14
+ if (!fs.existsSync(logPath)) {
15
+ console.log(errorsOnly ? 'No error logs found.' : 'No daemon logs found.');
27
16
  return;
28
17
  }
29
18
 
30
- const left = logLines.slice(-lines);
31
- const right = errorLines.slice(-lines);
32
-
33
- // Calculate column widths
34
- const leftWidth = Math.max(40, ...left.map((l) => l.length));
35
- const rightWidth = Math.max(40, ...right.map((l) => l.length));
36
-
37
- // Print header
38
- const leftHeader = 'Other Logs'.padEnd(leftWidth);
39
- const rightHeader = 'Errors'.padEnd(rightWidth);
40
- console.log(`${leftHeader} | ${rightHeader}`);
41
- console.log('-'.repeat(leftWidth) + '-+-' + '-'.repeat(rightWidth));
42
-
43
- // Print lines side by side
44
- for (let i = 0; i < lines; i++) {
45
- const l = left[i] !== undefined ? left[i] : '';
46
- const r = right[i] !== undefined ? right[i] : '';
47
- console.log(l.padEnd(leftWidth) + ' | ' + r.padEnd(rightWidth));
19
+ const logContent = fs.readFileSync(logPath, 'utf-8');
20
+ const logLines = logContent.split('\n');
21
+ const lastLines = logLines.slice(-lines);
22
+ if (errorsOnly) {
23
+ console.log('--- Error Logs ---');
24
+ } else {
25
+ console.log('--- Daemon Logs ---');
48
26
  }
27
+ lastLines.forEach((line) => console.log(line));
49
28
  }