date: match GNU's error for a bad --iso-8601 or --rfc-3339 value - #14305
Closed
arbelonson-source wants to merge 1 commit into
Closed
date: match GNU's error for a bad --iso-8601 or --rfc-3339 value#14305arbelonson-source wants to merge 1 commit into
arbelonson-source wants to merge 1 commit into
Conversation
--iso-8601 and --rfc-3339 validated their value with a plain
ShortcutValueParser, so an unrecognized or ambiguous value produced
clap's own wording ("error: invalid value 'X' for '--iso-8601 [<FMT>]'
... [possible values: ...]") instead of GNU's ("date: invalid argument
'X' for '--iso-8601' / Valid arguments are: / ... / Try 'date --help'
for more information.").
Resolve the value against each option's own choice list by hand,
accepting any unambiguous abbreviation the way GNU does, and report
GNU's wording (and its distinct 'ambiguous argument' message) when it
does not.
AI-assisted-by: Claude Opus 5, via Claude Code
This was referenced Aug 31, 2026
Contributor
|
see #14308 (comment) |
Merging this PR will improve performance by 3.82%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Memory | single_date_now |
15.6 KB | 15 KB | +4.07% |
| ⚡ | Memory | complex_relative_date |
16.8 KB | 16.2 KB | +3.76% |
| ⚡ | Simulation | single_date_now |
173.7 µs | 167.6 µs | +3.65% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing arbelonson-source:fix/date-iso8601-rfc3339-invalid-choice (0677f28) with main (3251833)
Footnotes
-
402 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
|
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
--iso-8601and--rfc-3339validate their value with a plainShortcutValueParser, so an unrecognized or ambiguous value producesclap's own generic wording instead of GNU's.
Fix
Resolve the value against each option's own choice list by hand
(matching GNU's per-option order), accepting any unambiguous
abbreviation the way GNU does, and report GNU's wording -- including
its distinct "ambiguous argument" message when the value could name
more than one choice -- when it does not resolve. Same fix already
shipped for
wc --total,sort --parallel, anduniq --group/--all-repeated(#14293, #14303, #14304).Note:
date --rfc-3339with no value supplied at all (not even anempty string) still gets clap's own "a value is required for ... but
none was supplied" message rather than GNU's "option '--rfc-3339'
requires an argument". That's a separate, shared-infrastructure
mismatch in
clap_localization.rs's handling ofErrorKind::InvalidValuethat affects other utilities too, not something specific to this
option -- left out of this PR to keep it focused.
Testing
cargo test -p uu_date/ fulltests/by-util/test_date.rssuite: 154 passed, 0 failed.--iso-8601value, an ambiguous--iso-8601value, and an invalid--rfc-3339value.--iso-8601/--rfc-3339value (valid, invalid, ambiguous prefix, empty) against GNU date 9.11 underLC_ALL=C.cargo clippy -p uu_date --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.