Skip to content

fix(cli): suggest the nearest top-level flag for a misspelled one - #8687

Merged
EffortlessSteven merged 7 commits into
mainfrom
claude/dx-flag-typo
Oct 21, 2026
Merged

EffortlessSteven merged 7 commits into
mainfrom
claude/dx-flag-typo

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Governing issue or accepted claim: 0.11 experience and reliability line (release map #2379), newcomer first-run polish campaign; no dedicated issue.
Acceptance delta (one sentence): A misspelled top-level flag such as ripr --versoin names the nearest of --version and --help instead of the "options go after the command" message, which is wrong for it.

Before: on current main ripr --versoin prints options go after the command, e.g. ripr check --versoin ..., which misleads someone who only mistyped --version.

After: it prints unknown command "--versoin". Did you mean --version? Run ripr --help. Likewise --hepl suggests --help. Flags far from both (--root, --base, --bogus) keep main's options-go-after-the-command message.

How: the dash-prefixed branch of unknown_command_error first asks the edit-distance matcher over --version/--help; unit tests cover near (--versoin, -version, --hepl) and far cases. cargo test -p ripr --lib cli::command and cargo xtask check-process-policy pass on the merged head.


🤖 Generated with Claude Code

https://claude.ai/code/session_01XPNmeJoSKoX2dJijL5sy3F

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 86 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 26359f49-df0c-445e-b385-9e783012ad25
📥 Commits

Reviewing files that changed from the base of the PR and between 601b3a4 and a357ea7.

📒 Files selected for processing: 2
  • changelog.d/top-level-flag-typo-suggestion.md
  • crates/ripr/src/cli/command.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XPNmeJoSKoX2dJijL5sy3F
@EffortlessSteven EffortlessSteven self-assigned this Oct 18, 2026
@EffortlessSteven
EffortlessSteven marked this pull request as draft October 18, 2026 03:01
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 18, 2026 03:01
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copy link
Copy Markdown
Member Author

Ripr Rust Small fails only in lsp::tests::generic_client_analysis_failure_is_shown_once_and_only_to_generic_clients, the same test that is red on main (see the comment on #8650). This PR touches only cli/command.rs and a changelog fragment; its own new test passes. The LSP thread owns the fix. Once it lands I will merge main in and re-qualify this head.


Generated by Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision

  • Needs one verification check before upstream.

Verification questions

  • Confirm test misses -h/--help misspelling (e.g. --hepl) and does not cover dash-prefixed but-not-flag inputs (e.g. 'help'). Submaterial gap.

Refuted

  • Closest_of duplicates closest_command and should be inlined or generalized via an Option<&[&'static str]> parameter rather than a sibling helper.; refuted because: The helper is module-private, only one new call site, and the explicit dispatch on command.starts_with('-') at the unknown_command_error call site keeps the two suggestion domains visually distinct; refactoring to pass candidates through closest_command would entangle the flag-only domain with the subcommand domain for negligible LOC savings.
  • Allocation-failure / Box-from-slice path could be triggered by extra iterator allocation in closest_of via .iter().copied().; refuted because: No allocation failure path is introduced by this diff; .iter().copied() over a small static slice is not a Box allocation, and the diff does not touch allocator or Box::from paths. Calibration: this objection is out of scope for the current PR.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • The seeded review requested --help and dash-prefixed non-flag coverage. Add compact assertions for --hepl selecting --help and for a dash-prefixed non-flag preserving the no-invented-suggestion route.

Verification questions

  • Confirm the prior missing-help-typo coverage remains open, but it is submaterial: --versoin proves both configured flag candidates are consulted, while the near/far threshold behavior is covered.
  • Confirm the new --help suggestion path is logically reachable and produces the nearest candidate, although it is not asserted by name.
  • Confirm the test does not prove the broader claim that the nearest of --version and --help is selected.
  • Confirm dash-prefixed non-flag text enters the same route, but its behavior is not explicitly covered.
  • Confirm the new route can select --help, but the added test only proves selection of --version; a near-help typo such as --hepl is not covered.

Refuted

  • Generalizing the matcher could accidentally suggest flags for ordinary unknown commands.; refuted because: The flag route remains guarded by command.starts_with('-'); closest_command still receives known_commands(), and --bogus exercises the far-flag fallback.
  • The helper change could cause unrelated command typos to be matched against flags.; refuted because: Call-site dispatch is separate: flag-position input passes the explicit two-flag slice, while closest_command passes known_commands(); the focused tests also preserve the far-flag fallback.
  • Adding a dash-prefix branch with its own suggestion set could mask or override a future subcommand that legitimately begins with '-' (e.g. a hidden --version alias subcommand) by emitting a did-you-mean to --version/--help first.; refuted because: Subcommands are registered via the standard clap derive dispatch that feeds unknown_command_error; there is no subcommand whose name literally starts with '-' in this crate, and clap's own unknown-command surface remains the primary path. The dash-prefix branch only runs after clap already refused the input, so no clap-parsed subcommand name starting with '-' can reach it.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XPNmeJoSKoX2dJijL5sy3F

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • --hepl and dash-prefixed non-flag behaviors are reachable but unasserted; route is correct on inspection, so this is a coverage gap rather than a defect.

Verification questions

  • Confirm new test only asserts --versoin and --bogus; --hepl suggestion for --help is not directly asserted despite the PR description claiming the matcher covers both.
  • Confirm dash-prefixed but not a flag (e.g. '-foo' without '--') enters the same starts_with('-') branch and may now receive a flag suggestion where none existed before.

Refuted

  • Generalizing the matcher could accidentally suggest flags for ordinary unknown subcommands; refuted because: The flag route is still guarded by command.starts_with('-') at the unknown_command_error call site; the new closest_of helper is parameterized but only the new flag call passes ['--version','--help'] while closest_command keeps using known_commands(), so subcommand and flag suggestion domains stay disjoint.
  • closest_of duplicates closest_command and should be inlined or generalized via Option<&[&'static str]> parameter rather than as a sibling helper.; refuted because: The helper is module-private, has exactly one new call site, and explicit dispatch on command.starts_with('-') at unknown_command_error keeps the two suggestion domains visually distinct; refactoring to pass candidates through closest_command would entangle the flag-only domain with the subcommand domain for negligible LOC savings. Matches prior seeded review.
  • Allocation-failure / Box-from-slice path could be triggered by closest_of's .iter().copied() iterator allocation.; refuted because: Closest_of iterates a static &'static [&'static str] slice via .iter().copied(); no Box, allocator, or fallible allocation is introduced; out of scope for this diff.

Parked follow-ups

  • The test proves the claimed examples and threshold fallback, but not exhaustive nearest-winner behavior for arbitrary edit-distance ties or inputs.
  • closest_of's slice-of-static-strs signature is acceptable for current scale but represents a future-proofing risk: if a second flag-aware site lands, the helper either gets re-parameterized or copied; parked for the next expansion.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XPNmeJoSKoX2dJijL5sy3F

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

Devin Review

Comment thread crates/ripr/src/cli/command.rs Resolved
Comment thread crates/ripr/src/cli/command.rs Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reporter summary

The diff is correct and well-scoped: closest_of parameterizes the budget-scaled edit-distance matcher over a static slice, the dash-prefixed branch now suggests --version/--help, the new test covers --versoin, -version, --hepl, and --bogus, and previously raised concerns (helper duplication, allocation paths, subcommand contamination) are refuted by the diff. The remaining gap is trust-affecting: cargo-test timed out after 900s and ripr failed (exit 2); both are environmental (LSP failure in lsp::tests::generic_client_analysis_failure_is_shown_once_and_only_to_generic_clients is also red on main per the PR thread), not localized to cli/command.rs. Recommend re-running cargo-test for the cli::command tests and ripr under lighter load and merging once those receipts land.

…ep placement guidance

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XPNmeJoSKoX2dJijL5sy3F

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refuted

  • Box::from(slice)/allocation-failure path introduced by .iter().copied() in closest_of; refuted because: diff contains no Box::from or allocator changes; .iter().copied() over a static slice is not a Box allocation.
  • Generalizing closest_command creates a route where ordinary unknown subcommands receive flag suggestions.; refuted because: Candidate domains remain separate: closest_command passes known_commands(), while only the dash-prefixed branch passes --version/--help.
  • Failure path: --versoin matcher could match --help (distance 5) instead of --version (distance 2).

Parked follow-ups

  • A separate spec file for this user-facing error wording was explicitly considered and rejected by the author; this is a parked policy follow-up, not a current correctness defect.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • The implementation route is locally validated, but executable trust evidence remains incomplete.

@EffortlessSteven
EffortlessSteven merged commit 04e5236 into main Oct 21, 2026
51 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/dx-flag-typo branch October 21, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants