Repository navigation
fix: accept repeated options like GNU grep - #2
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2 +/- ##
=======================================
Coverage 94.95% 94.96%
=======================================
Files 6 6
Lines 1408 1409 +1
Branches 140 140
=======================================
+ Hits 1337 1338 +1
Misses 69 69
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Enables GNU grep-compatible handling of repeated CLI options by configuring clap to override (rather than error) on repeated flags, while preserving accumulation semantics for ArgAction::Append args. Adds a regression test covering booleans, value options, and append options.
Changes:
- Add
.args_override_self(true)to the top-leveluu_app()clapCommand. - Add
repeated_options_are_acceptedregression test covering-n -n,-i -i,-m 5 -m 1, and-e a -e b.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/lib.rs | Enables clap's args_override_self so repeated options replace instead of error. |
| tests/test_grep.rs | Adds regression test verifying repeated booleans, last-wins value option, and -e accumulation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3d78ca7 to
8793b49
Compare
|
fuzzers rock! |
GNU grep tolerates options given more than once (boolean flags are idempotent, value options take the last occurrence), but clap rejected them with "cannot be used multiple times" (exit 2). Set args_override_self(true) so clap replaces rather than errors; args with ArgAction::Append (-e/-f/--include/--exclude) still accumulate. Found by the differential fuzzer (e.g. `grep -e .* -E -n -o -n -x`). Add a regression test covering repeated booleans, repeated value options (last wins), and that -e still accumulates patterns.
8793b49 to
c2cac0a
Compare
GNU grep tolerates options given more than once (boolean flags are idempotent, value options take the last occurrence), but clap rejected them with "cannot be used multiple times" (exit 2). Set args_override_self(true) so clap replaces rather than errors; args with ArgAction::Append (-e/-f/--include/--exclude) still accumulate.
Found by the differential fuzzer (e.g.
grep -e .* -E -n -o -n -x).Add a regression test covering repeated booleans, repeated value options (last wins), and that -e still accumulates patterns.