Skip to content

Treat unknown flag arguments as errors instead of positional args #1801

Description

@Widthdom

Summary

The QueryCommandRunner argument parser (QueryCommandRunner.cs:3001-3009) routes unknown flags to a default branch that, when allowNamedQuery is true, treats the unknown flag as a positional query literal. So cdidx search foo --dapth 3 (typo for --depth) is parsed as a query for the literal --dapth followed by 3 — a near-zero-result silent failure rather than an "unknown flag" error. Users believe they passed --depth and get a nonsense answer.

Where

  • src/CodeIndex/Cli/QueryCommandRunner.cs:3001-3009 (parser default branch)

Suggested approach

(1) Reject any token starting with -- in the default branch with a clear "unknown option --dapth" error, regardless of allowNamedQuery. Positional queries that legitimately start with -- can be supported via the explicit -- separator. (2) Cross-reference with #1582 (did-you-mean for flags) — once unknown flags are surfaced, the suggester can run. (3) Add a regression test for cdidx search foo --dapth 3 asserting an error exit and an unknown-flag message. (4) Apply the same fix to other command runners with default-branch positional fallthrough. (5) Document under "Argument parsing rules".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions