Summary
After the subcommand keyword, unknown flag-shaped tokens (e.g., cdidx search foo --baar where --baar is misspelled) are silently consumed as positional argument strings instead of rejected as unknown flags. The user sees a search for the literal string foo --baar (or worse, no error and an empty result), which is confusing and invites copy-paste mistakes from other CLIs that accept slightly different flag spellings.
Where
src/CodeIndex/Cli/QueryCommandRunner.cs:3001-3005 (ParseArgs default branch swallows unknown --* tokens into positional list)
- Same pattern likely repeats in
IndexCommandRunner.cs
Suggested approach
(1) In the parser's default case, if a token starts with - or -- and is not a recognized flag, return a parse error rather than appending to positionals. (2) Pair the rejection with a "Did you mean --<closest>?" hint (companion to #1582 which covers the same for top-level subcommands but not for per-subcommand flags). (3) Add an explicit -- separator to allow callers who genuinely want a leading-dash positional to opt in. (4) Cover with regression tests: search foo --baar exits non-zero with hint; search foo -- --baar succeeds and treats --baar as positional.
Summary
After the subcommand keyword, unknown flag-shaped tokens (e.g.,
cdidx search foo --baarwhere--baaris misspelled) are silently consumed as positional argument strings instead of rejected as unknown flags. The user sees a search for the literal stringfoo --baar(or worse, no error and an empty result), which is confusing and invites copy-paste mistakes from other CLIs that accept slightly different flag spellings.Where
src/CodeIndex/Cli/QueryCommandRunner.cs:3001-3005(ParseArgs default branch swallows unknown--*tokens into positional list)IndexCommandRunner.csSuggested approach
(1) In the parser's default case, if a token starts with
-or--and is not a recognized flag, return a parse error rather than appending to positionals. (2) Pair the rejection with a "Did you mean--<closest>?" hint (companion to #1582 which covers the same for top-level subcommands but not for per-subcommand flags). (3) Add an explicit--separator to allow callers who genuinely want a leading-dash positional to opt in. (4) Cover with regression tests:search foo --baarexits non-zero with hint;search foo -- --baarsucceeds and treats--baaras positional.