Repository navigation
grep: test long options against a prefix list - #259
yunusarda-sudo wants to merge 1 commit into
Conversation
…'s arguments Follow-up to uutils#239 as suggested by lhecker: keep the list of long options taking a value and match the (possibly abbreviated) name by prefix. A unit test keeps the list in sync with uu_app(), and uu_app() is built once again.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #259 +/- ##
==========================================
- Coverage 97.22% 97.22% -0.01%
==========================================
Files 6 6
Lines 2270 2267 -3
Branches 245 244 -1
==========================================
- Hits 2207 2204 -3
Misses 63 63
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
| /// the next argument. `name` may be any prefix of an option, as accepted by | ||
| /// `infer_long_args`. A prefix that is ambiguous is rejected by clap anyway. | ||
| fn long_option_takes_next_arg(name: &[u8]) -> bool { | ||
| // `--binary` is a flag of its own, though also a prefix of `--binary-files`. | ||
| name != b"binary" | ||
| && LONG_OPTS_WITH_VALUE | ||
| .iter() | ||
| .any(|opt| opt.as_bytes().starts_with(name)) | ||
| } |
There was a problem hiding this comment.
I don't believe this is correct. E.g. --e should not match exclude, because it is not unique.
Follow-up to #239, as lhecker suggested there: instead of walking
Command::get_arguments(), keepLONG_OPTS_WITH_VALUEand test the (possibly abbreviated) name by prefix.--binaryis special-cased since it is a flag and also a prefix of--binary-files. A unit test keeps the list in sync withuu_app(), andexpand_num_shorthandno longer needs theCommand.