Repository navigation
Conversation
| } | ||
| } | ||
|
|
||
| // Clap otherwise consumes the next operand as the optional width value. |
There was a problem hiding this comment.
--strings file has the same issue, no? could be a follow-up
| }) | ||
| }); | ||
| if long_width { | ||
| arg.push_str("=32"); |
There was a problem hiding this comment.
"32" is now duplicated with default_missing_value("32"), could you please use a const?
2463acf to
425c474
Compare
|
| .skip(1) | ||
| .take_while(|arg| arg.as_str() != "--") | ||
| { | ||
| let long_width = arg.starts_with("--w") && "--width".starts_with(arg.as_str()); |
There was a problem hiding this comment.
the hardcoded --w/--st prefixes will silently break if a new long option is added, could you resolve them from command like for the short flags?
in general, trying to do clap job is HARD
There was a problem hiding this comment.
Fixed in 23f2082. The lookup now uses the options and aliases declared on the clap Command. Exact names win, and a prefix gets a default only when it identifies one option. I added a regression test with a second --widths option so --wid stays ambiguous while --width still works.
| } | ||
|
|
||
| // Attach missing optional values so Clap keeps the next operand as a filename. | ||
| fn default_optional_value_args(args: &[String], command: &Command) -> Vec<String> { |
There was a problem hiding this comment.
did you run the GNU od tests with this?
git clone https://github.com/coreutils/coreutils.git ../gnu
bash util/build-gnu.sh && bash util/run-gnu-test.sh tests/od/od.pl
There was a problem hiding this comment.
Ran the requested build and tests/od/od.pl against GNU 9.12. It passed 20 of 26 cases on both this commit and the unmodified base. The same six quoting and overflow cases failed, with identical diagnostics and exit statuses. All seven companion GNU od shell tests passed.
425c474 to
23f2082
Compare
Apply the default width when -w or --width has no attached value, keeping the following filename as an operand. Preserve attached widths, combined short flags, and operands after --.
Closes #10725.