Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/cli/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --help hint belongs at the render layer in index.ts, not embedded in Error.message. Error.message is a programmatic value - callers that catch this error get a string that mixes the machine-readable fact (Unknown option: --foo) with display copy. The catch block in index.ts is already the right place to append the hint, and it already does so. Keep the throw messages clean.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting: the hint is applied to 3 of the 6 throw sites in args.ts - the config and overrides subcommand blocks are untouched. If the approach were correct, coverage would need to be consistent across all sites.

}
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 };
Expand All @@ -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 };
}
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ try {
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error(chalk.red(`Error: ${message}`));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard exists because embedding the hint in Error.message above created a duplication problem that now needs papering over. The substring check is also fragile - any future error message that legitimately contains --help (e.g. "--help-url requires a value") will silently suppress the hint. Keeping the throw messages clean removes the need for this guard entirely.

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);
}

Expand Down