du: match GNU's error for a bad --time value, fix --time-style's help hint - #14306
Closed
arbelonson-source wants to merge 1 commit into
Closed
du: match GNU's error for a bad --time value, fix --time-style's help hint#14306arbelonson-source wants to merge 1 commit into
arbelonson-source wants to merge 1 commit into
Conversation
… hint --time validated its value with a plain ShortcutValueParser, so an unrecognized or ambiguous value (e.g. --time=bogus) produced clap's own generic wording instead of GNU's grouped-alias 'invalid argument ... for --time / Valid arguments are: / - 'atime', 'access', 'use' / ...'. Resolve the value against the option's own alias groups by hand, accepting any unambiguous abbreviation the way GNU does (including one ambiguous only between aliases of the same choice), and report GNU's wording -- extended with this implementation's own 'creation'/'birth' choice, which GNU's --time does not support at all -- when it does not resolve. Also fixes an unrelated, adjacent bug in the same error family: --time-style's own invalid-argument message already had GNU's wording, but its 'Try ... for more information' hint used uucore::execution_phrase() (just the invoked binary, e.g. 'target/debug/du') without appending '--help', and quoted full-iso/long-iso/iso where GNU does not. AI-assisted-by: Claude Opus 5, via Claude Code
This was referenced Aug 31, 2026
Contributor
|
see #14308 (comment) |
|
GNU testsuite comparison: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
--timevalidates its value with a plainShortcutValueParser, so anunrecognized or ambiguous value produces clap's own generic wording
instead of GNU's grouped-alias wording:
Fix
Resolve the value against the option's own alias groups by hand,
accepting any unambiguous abbreviation the way GNU does -- including
one that's ambiguous only between aliases of the same choice (e.g.
--time=aunambiguously meansatime/access/use) -- and reportGNU's wording, extended with one more group for this implementation's
own
creation/birthchoice, which GNU's--timedoes not supportat all. Since that's a real extra choice this implementation accepts,
--time=cis genuinely ambiguous here (betweenctimeandcreation) even though it isn't in GNU.Same fix already shipped for
wc --total,date --iso-8601/--rfc-3339,sort --parallel, anduniq --group/--all-repeated(#14293, #14303,#14304, #14305).
Also fixed
An unrelated but adjacent bug in the same error family:
--time-style'sown invalid-argument message already had GNU's wording, but its "Try
... for more information" hint used
uucore::execution_phrase()(justthe invoked binary, e.g.
target/debug/du) without appending--help, and quotedfull-iso/long-iso/isowhere GNU does not:Testing
cargo test -p uu_du/ fulltests/by-util/test_du.rssuite: 122 passed, 0 failed.--timevalue, an ambiguous one (c), and the fixed--time-stylehint.--timevalue (all real GNU choices/aliases,creation/birth, invalid, ambiguous, empty) against GNU du 9.11 underLC_ALL=C.cargo clippy -p uu_du --all-targets -- -D warningsandcargo fmt --check: clean.This PR was written with AI assistance (Claude Opus 5, via Claude Code). I've tested the changes but please review the code carefully.