mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
fix: match date -I error messages with GNU date (#4499)
* date: use value_parser to improve errors * date: update panic! to unreachable inside impl From for Iso8601Format
This commit is contained in:
parent
4e03e6254f
commit
bd6905cf59
2 changed files with 10 additions and 2 deletions
|
@ -114,8 +114,8 @@ impl<'a> From<&'a str> for Iso8601Format {
|
|||
SECONDS | SECOND => Self::Seconds,
|
||||
NS => Self::Ns,
|
||||
DATE => Self::Date,
|
||||
// Should be caught by clap
|
||||
_ => panic!("Invalid format: {s}"),
|
||||
// Note: This is caught by clap via `possible_values`
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -291,6 +291,7 @@ pub fn uu_app() -> Command {
|
|||
.short('I')
|
||||
.long(OPT_ISO_8601)
|
||||
.value_name("FMT")
|
||||
.value_parser([DATE, HOUR, HOURS, MINUTE, MINUTES, SECOND, SECONDS, NS])
|
||||
.help(ISO_8601_HELP_STRING),
|
||||
)
|
||||
.arg(
|
||||
|
|
|
@ -50,6 +50,13 @@ fn test_date_rfc_8601() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_rfc_8601_invalid_arg() {
|
||||
for param in ["--iso-8601", "--i"] {
|
||||
new_ucmd!().arg(format!("{param}=@")).fails();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_rfc_8601_second() {
|
||||
for param in ["--iso-8601", "--i"] {
|
||||
|
|
Loading…
Reference in a new issue