rm: match GNU's error for a bad --interactive value - #14309
rm: match GNU's error for a bad --interactive value#14309arbelonson-source wants to merge 1 commit into
Conversation
--interactive validated its value with a plain ShortcutValueParser, so
an unrecognized or ambiguous value produced clap's own generic wording
instead of GNU's grouped-alias wording ('invalid argument ... for
--interactive / Valid arguments are: / - 'never', 'no', 'none' / ...').
Resolve the value against the option's own alias groups by hand,
accepting any unambiguous abbreviation the way GNU does -- including
one ambiguous only between aliases of the *same* choice, e.g. 'n'
among 'never'/'no'/'none', or 'a'/'y' for 'always'/'yes' -- and report
GNU's wording, in GNU's own group order (never/no/none, once,
always/yes), when it does not resolve.
AI-assisted-by: Claude Opus 5, via Claude Code
|
Sorry, but I really don't hope increacing complexity just for matching error message with GNU by removing clap's control. |
Merging this PR will improve performance by 3.26%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | rm_single_file |
104 ms | 100.7 ms | +3.26% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing arbelonson-source:fix/rm-interactive-invalid-choice (d67cbb2) with main (3251833)
Footnotes
-
404 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
GNU testsuite comparison: |
What
--interactivevalidates its value with a plainShortcutValueParser,so an unrecognized or ambiguous value produces clap's own generic
wording instead of GNU's grouped-alias wording:
Fix
Same fix already shipped for
wc --total,date --iso-8601/--rfc-3339,du --time,sort --parallel,uniq --group/--all-repeated,shred --remove, andtee --output-error(#14293, #14303-#14308): resolvethe value against the option's own alias groups by hand, accepting any
unambiguous abbreviation the way GNU does -- including one ambiguous
only between aliases of the same choice, e.g.
namongnever/no/none, ora/yforalways/yes-- and report GNU'swording when it doesn't resolve, in GNU's own group order
(
never/no/none,once,always/yes-- notably not theorder this option's choices were declared in).
Testing
cargo test -p uu_rm/ fulltests/by-util/test_rm.rssuite: 85 passed, 0 failed.n) is still accepted.--interactivevalue (all real choices/aliases/abbreviations, invalid, ambiguous, empty) against GNU rm 9.11 underLC_ALL=C.cargo clippy -p uu_rm --all-targets -- -D warningsandcargo fmt --check: clean.This PR was written with AI assistance (Claude Opus 5, via Claude Code). I've tested the changes but please review the code carefully.