touch: match GNU's error for a bad --time value - #14311
Closed
arbelonson-source wants to merge 1 commit into
Closed
Conversation
--time validated its value with a plain ShortcutValueParser, so an
unrecognized or ambiguous value produced clap's own generic wording
instead of GNU's grouped-alias wording ('invalid argument ... for
--time / Valid arguments are: / - 'atime', 'access', 'use' / ...').
Same fix already shipped for the same option name on wc, date, du,
sort, uniq, shred, tee, rm (uutils#14293, uutils#14303-uutils#14310): 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, e.g. 'a' among
'atime'/'access'/'use' -- and report GNU's wording when it does not
resolve. determine_atime_mtime_change now returns a UResult to
propagate that.
AI-assisted-by: Claude Opus 5, via Claude Code
Contributor
|
We don't need to cover all equivalent aliases in the error message since there is @arbelonson-source Would you stop aligning error message with GNU if it does not cause actual misleading? |
|
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
Same fix already shipped for the same option name on other utilities,
and for other options generally, across this series (#14293, #14303-
#14310): 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,
e.g.
aamongatime/access/use-- and report GNU's wording whenit does not resolve.
determine_atime_mtime_changenow returns aUResult<ChangeTimes>instead of a bare
ChangeTimesto propagate that; the existing unittest for it (
test_determine_atime_mtime_change) is updated to.unwrap()accordingly.Testing
cargo test -p uu_touch(lib + integration): 6 + 65 passed, 0 failed.--timevalue (all real choices/aliases/abbreviations, invalid, ambiguous, empty) against GNU touch 9.11 underLC_ALL=C.--time=atime/--time=mtimestill update the correct timestamp (not just the error path).cargo clippy -p uu_touch --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.