Skip to content

Commit 6df7d4e

Browse files
committed
refactor: drop as-any casts and note the cli.ts sync requirement
Review follow-ups: widen the command lists to readonly string[] instead of narrowing the value, and document that isCommandKnown must stay in sync with the cli.ts dispatch fall-through.
1 parent 870f548 commit 6df7d4e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/cli/parser/args.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,14 @@ function normalizeParsedCommandAliases(parsed: ParsedArgs): ParsedArgs {
347347
}
348348

349349
function isCommandKnown(command: string): boolean {
350+
// Must stay in sync with the authoritative dispatch fall-through in
351+
// cli.ts ("Unknown command"): any command runnable there must be listed in
352+
// the catalog (or below), or this early check rejects it at parse time.
350353
// 'help' is handled specially in cli.ts and is not in the command catalog
351354
if (command === 'help') return true;
352355
// Internal commands are handled specially in cli.ts
353-
if (Object.values(INTERNAL_COMMANDS).includes(command as any)) return true;
354-
return listCliCommandNames().includes(command as any);
356+
if ((Object.values(INTERNAL_COMMANDS) as readonly string[]).includes(command)) return true;
357+
return (listCliCommandNames() as readonly string[]).includes(command);
355358
}
356359

357360
const COMMAND_ALIAS_SUGGESTIONS: Record<string, string> = {

0 commit comments

Comments
 (0)