Repository navigation
diff: accept -W N, -WN, --width N and --tabsize N option forms - #424
Conversation
Accept separate arguments (-W N, --width N, --tabsize N) and attached short option (-WN) in addition to attached long options (--width=N, --tabsize=N). Fixes uutils#396
Merging this PR will improve performance by 33.75%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing |
| /// `long` is given, if `param` is that option. | ||
| fn option_argument<'a>(param: &'a OsStr, short: &str, long: &str) -> Option<OptionArgument<'a>> { | ||
| if param == short || param == long { | ||
| if (!short.is_empty() && param == short) || (!long.is_empty() && param == long) { |
There was a problem hiding this comment.
could be simpler with short: Option<&str> instead of the empty-string checks, no?
There was a problem hiding this comment.
Done in commit e680053: changed short to Option<&str>.
| .args(&["w1", "w2"]) | ||
| .succeeds() | ||
| .stderr_is("") | ||
| .stdout_contains("x ") |
There was a problem hiding this comment.
please check the exact output with stdout_is, "x " is a weak check
There was a problem hiding this comment.
Done in commit e680053: changed to exact stdout_is assertion.
| .args(&["w1", "w2"]) | ||
| .succeeds() | ||
| .stderr_is("") | ||
| .stdout_is("x <\n >\ty\n"); |
There was a problem hiding this comment.
GNU prints x | y here (see #396), so this pins our side_diff divergence
could you please add a comment or open an issue for it?
…argument-forms # Conflicts: # tests/by-util/test_diff.rs
|
Hi! I noticed that this PR addresses almost the same changes as my PR #400. My PR already includes the requested changes for Would you prefer to continue with this PR, or should I keep working on #400 and close one of them to avoid duplicate work? I'm happy to follow whichever approach is easier for maintainers. |
|
Hi @dex0o0 — thanks for flagging the overlap, and sorry I missed #400 when I opened this. You're right that both PRs fix #396 the same way: they drop the You opened first (Nov 15 vs Nov 19), already addressed Sylvestre's request to include The one thing #424 still has on top is a slightly broader test surface from review here: all four width spellings, exact missing/invalid-argument messages (exit 2), and a short comment pinning the current Happy to follow whatever the maintainers prefer. |
|
@yunusarda-sudo I really appreciate the work you've put into your PR. I think it's best to leave the decision to the maintainers and follow whatever they consider the best approach. Thanks again for being so understanding! |
|
Thanks for your PR |
Accept separate argument forms (
-W N,--width N,--tabsize N) and attached short option (-WN) in addition to attached long option formats (--width=N,--tabsize=N), matching GNU diff.Changes
--width=Nand--tabsize=Nwithoption_argumentandargument_value.option_argumentso emptyshort/longprefixes do not inadvertently match.src/params.rsfor all argument forms and error cases.tests/by-util/test_diff.rscovering option forms and missing/invalid arguments.Fixes #396