mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(cli): report an invalid catalog --type as a usage error (#7678)
`catalog --type widget` exited 1 with a runtime_error. A bad flag value is a usage mistake, so it now throws CliUsageError: exit 2, and under --json a usage_error envelope with the same message. Closes #7669 Claude-Session: https://claude.ai/code/session_01M3Xbw44WYGyVqg4AjkzFxj Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -234,6 +234,7 @@ describe("agent-mode contract", () => {
|
||||
["compare a.html b.html --timeout abc", "--timeout must be a positive integer"],
|
||||
["compare a.html b.html --timeout -1", "--timeout must be a positive integer"],
|
||||
["grade-compare --for frame.png", "Exactly one of --grades or --luts"],
|
||||
["catalog --type widget", 'Invalid --type: "widget". Use "block" or "component".'],
|
||||
["check --range 5,1", "Invalid --range"],
|
||||
["check --samples ten", "Invalid --samples"],
|
||||
["check --tolerance=-1", "Invalid --tolerance"],
|
||||
|
||||
@@ -17,7 +17,7 @@ import { loadAllItems } from "../registry/resolver.js";
|
||||
import { readRegistryManifest } from "../registry/remote.js";
|
||||
import { loadProjectConfig, DEFAULT_PROJECT_CONFIG } from "../utils/projectConfig.js";
|
||||
import { relative, resolve } from "node:path";
|
||||
import { finishCommand } from "../utils/commandResult.js";
|
||||
import { CliUsageError, finishCommand } from "../utils/commandResult.js";
|
||||
import { isUnattended } from "../utils/attendedTerminal.js";
|
||||
import { runAdd } from "./add.js";
|
||||
import { hasNoSearchableTokens, searchByWords } from "../registry/localSearch.js";
|
||||
@@ -226,8 +226,7 @@ export default defineCommand({
|
||||
if (args.type === "block") typeFilter = "hyperframes:block";
|
||||
else if (args.type === "component") typeFilter = "hyperframes:component";
|
||||
else if (args.type) {
|
||||
console.error(`Invalid --type: "${args.type}". Use "block" or "component".`);
|
||||
finishCommand(1);
|
||||
throw new CliUsageError(`Invalid --type: "${args.type}". Use "block" or "component".`);
|
||||
}
|
||||
|
||||
// Asked for the whole manifest on purpose: its item list defines coverage,
|
||||
|
||||
Reference in New Issue
Block a user