From 43f7751e6f8f59012b529687cf43abf8a0ea30eb Mon Sep 17 00:00:00 2001 From: goureeshreddy Date: Fri, 19 Jun 2026 21:40:02 +0530 Subject: [PATCH] feat: append --help hint to unknown option errors --- src/cli/args.ts | 12 ++++++------ src/index.ts | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/cli/args.ts b/src/cli/args.ts index 9b20a90f..f4f6a44b 100644 --- a/src/cli/args.ts +++ b/src/cli/args.ts @@ -51,9 +51,9 @@ export function parseArgs(argv: string[]): { continue; } if (arg.startsWith("-")) { - throw new Error(`Unknown option: ${arg}`); + throw new Error(`Unknown option: ${arg} Run \`cve-lite --help\` to see supported options.`); } - throw new Error(`Unexpected argument: ${arg}`); + throw new Error(`Unexpected argument: ${arg} Run \`cve-lite --help\` to see supported options.`); } return { command: "advisories-sync", options }; @@ -67,9 +67,9 @@ export function parseArgs(argv: string[]): { continue; } if (arg.startsWith("-")) { - throw new Error(`Unknown option: ${arg}`); + throw new Error(`Unknown option: ${arg} Run \`cve-lite --help\` to see supported options.`); } - throw new Error(`Unexpected argument: ${arg}`); + throw new Error(`Unexpected argument: ${arg} Run \`cve-lite --help\` to see supported options.`); } return { command: "install-skill", options }; } @@ -267,13 +267,13 @@ export function parseArgs(argv: string[]): { continue; } if (arg.startsWith("-")) { - throw new Error(`Unknown option: ${arg}`); + throw new Error(`Unknown option: ${arg} Run \`cve-lite --help\` to see supported options.`); } if (!projectArg) { projectArg = arg; continue; } - throw new Error(`Unexpected argument: ${arg}`); + throw new Error(`Unexpected argument: ${arg} Run \`cve-lite --help\` to see supported options.`); } if (options.cdx && options.report) { diff --git a/src/index.ts b/src/index.ts index 2c98f3aa..89adf172 100644 --- a/src/index.ts +++ b/src/index.ts @@ -74,7 +74,9 @@ try { } catch (error) { const message = error instanceof Error ? error.message : String(error); console.error(chalk.red(`Error: ${message}`)); - console.error(chalk.gray("Run `cve-lite --help` to see supported options.")); + if (!message.includes("--help")) { + console.error(chalk.gray("Run `cve-lite --help` to see supported options.")); + } process.exit(1); }