fix(cli): report an empty catalog --type= as a usage error (#8130)

`catalog --type=` passed an empty string, which the truthiness check
read as no filter: it listed every item and exited 0. Any given value
other than block or component is now a usage error (exit 2), as #7669
made it for other bad values.

Follow-up to #7678 review.


Claude-Session: https://claude.ai/code/session_01M3Xbw44WYGyVqg4AjkzFxj

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
James Varah
2026-11-19 16:03:36 +00:00
committed by GitHub
co-authored by Claude
parent a7d7a60754
commit c2911adc8d
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -235,6 +235,7 @@ describe("agent-mode contract", () => {
["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".'],
["catalog --type=", 'Invalid --type: "". Use "block" or "component".'],
["check --range 5,1", "Invalid --range"],
["check --samples ten", "Invalid --samples"],
["check --tolerance=-1", "Invalid --tolerance"],
+2 -1
View File
@@ -225,7 +225,8 @@ export default defineCommand({
let typeFilter: ItemType | undefined;
if (args.type === "block") typeFilter = "hyperframes:block";
else if (args.type === "component") typeFilter = "hyperframes:component";
else if (args.type) {
// An empty `--type=` is a typo too, not a request for no filter.
else if (args.type !== undefined) {
throw new CliUsageError(`Invalid --type: "${args.type}". Use "block" or "component".`);
}