Repository navigation
diff: add the program name and --help hint to the extra operand error - #368
Conversation
| params.executable.to_string_lossy() | ||
| )); | ||
| }; | ||
| if let Some((_, extra)) = opts.next() { |
There was a problem hiding this comment.
without --, diff a b c still says "Usage: diff "
the issue covers that case too, could you please use the same extra operand message there?
There was a problem hiding this comment.
Fixed: diff a b c now gets the same extra operand error as the -- case.
| if let Some((_, extra)) = opts.next() { | ||
| let exe = params.executable.to_string_lossy(); | ||
| return Err(format!( | ||
| "{exe}: extra operand '{}'\n{exe}: Try 'diff --help' for more information.", |
There was a problem hiding this comment.
why hardcode 'diff --help' when exe is used for the prefix?
There was a problem hiding this comment.
Right, it now uses exe for the --help hint too.
| ); | ||
| } | ||
| #[test] | ||
| fn extra_operand_after_double_dash() { |
There was a problem hiding this comment.
please add a test in tests/integration.rs too (exit code 2, empty stdout), and one for the case without --
There was a problem hiding this comment.
Added extra_operand_without_double_dash in tests/by-util/test_diff.rs (exit code 2, empty stdout, exact message). extra_operand_after_double_dash, now on main, covers the -- case the same way. I put them there because tests/integration.rs no longer exists on main.
Report "extra operand" with the --help hint and exit 2 instead of silently ignoring them. Fixes uutils#355. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
bf785bd to
090810c
Compare
|
Thanks for your PR |
Fixes #355.
Follow-up to 0567e1c, which rejects extra operands but prints a bare
extra operand 'X'. The error now readsdiff: extra operand 'X'followed bydiff: Try 'diff --help' for more information., on all three paths, using the executable name for both. Exit code is still 2. Addedextra_operand_without_double_dash(exit code 2, empty stdout, exact message).This change was written with AI assistance (Codex/Cursor) and I reviewed the diff and ran the checks myself; the implementation is written from the issue description, not derived from GNU source.
🤖 Generated with Claude Code