Skip to content

diff: accept -W N, -WN, --width N and --tabsize N option forms - #424

Open
yunusarda-sudo wants to merge 2 commits into
uutils:mainfrom
yunusarda-sudo:feat/width-tabsize-argument-forms
Open

yunusarda-sudo wants to merge 2 commits into
uutils:mainfrom
yunusarda-sudo:feat/width-tabsize-argument-forms

Conversation

@yunusarda-sudo

Copy link
Copy Markdown

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

  • Replaced regex matching of --width=N and --tabsize=N with option_argument and argument_value.
  • Guarded option_argument so empty short / long prefixes do not inadvertently match.
  • Added unit tests in src/params.rs for all argument forms and error cases.
  • Added integration tests in tests/by-util/test_diff.rs covering option forms and missing/invalid arguments.

Fixes #396

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
@codspeed

codspeed Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 33.71%

2 warnings

⚠️ 24 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran on different hardware

Its base and head results were measured on machines with a different CPU, core count or memory, so the change might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚡ 1 improved benchmark
✅ 25 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ diff_parser 5.7 ms 4.3 ms +33.71%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing yunusarda-sudo:feat/width-tabsize-argument-forms (dfdbea8) with main (824dfcf)

Open in CodSpeed

Comment thread src/params.rs Outdated
/// `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) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be simpler with short: Option<&str> instead of the empty-string checks, no?

Comment thread tests/by-util/test_diff.rs Outdated
.args(&["w1", "w2"])
.succeeds()
.stderr_is("")
.stdout_contains("x ")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check the exact output with stdout_is, "x " is a weak check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diff - -W N and --width N are rejected, only --width=N works

2 participants