From cc8855b90ff62d5c9d34d6f88ad6b4c259eb36fc Mon Sep 17 00:00:00 2001 From: Roger Chappel Date: Tue, 2 Jun 2026 16:50:27 +1000 Subject: [PATCH] Support CLI help and version flags --- package.json | 2 +- src/cli.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6b65cf7..48f7019 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "build": "tsc -p tsconfig.json", "check": "tsc -p tsconfig.json --noEmit", "test": "node --test --import tsx tests/*.test.ts", - "smoke": "npm run build && node dist/cli.js redact examples/agent-session.log --out /tmp/logveil-smoke.md --json-out /tmp/logveil-smoke.json && node dist/cli.js audit examples/agent-session.log --format json --fail-on none >/tmp/logveil-audit.json", + "smoke": "npm run build && node dist/cli.js --help | grep -q 'LogVeil' && node dist/cli.js --version | grep -q '0.1.0' && node dist/cli.js redact examples/agent-session.log --out /tmp/logveil-smoke.md --json-out /tmp/logveil-smoke.json && node dist/cli.js audit examples/agent-session.log --format json --fail-on none >/tmp/logveil-audit.json", "package:smoke": "npm pack --dry-run", "release:check": "npm test && npm run check && npm run build && npm run package:smoke" }, diff --git a/src/cli.ts b/src/cli.ts index 8465454..1325097 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -52,7 +52,12 @@ export async function main(argv = process.argv.slice(2)): Promise { function parseArgs(argv: string[]): CliOptions { const [commandRaw, ...rest] = argv; - const command = (commandRaw ?? "help") as CliOptions["command"]; + const normalizedCommand = commandRaw === "--help" || commandRaw === "-h" + ? "help" + : commandRaw === "--version" || commandRaw === "-v" + ? "version" + : commandRaw; + const command = (normalizedCommand ?? "help") as CliOptions["command"]; if (!["redact", "audit", "help", "version"].includes(command)) throw new Error(`Unknown command: ${commandRaw}`); const options: CliOptions = { command, inputs: [], format: command === "audit" ? "json" : "markdown", redact: true }; for (let i = 0; i < rest.length; i += 1) {