mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 23:02:38 +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,
|
SECONDS | SECOND => Self::Seconds,
|
||||||
NS => Self::Ns,
|
NS => Self::Ns,
|
||||||
DATE => Self::Date,
|
DATE => Self::Date,
|
||||||
// Should be caught by clap
|
// Note: This is caught by clap via `possible_values`
|
||||||
_ => panic!("Invalid format: {s}"),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -291,6 +291,7 @@ pub fn uu_app() -> Command {
|
||||||
.short('I')
|
.short('I')
|
||||||
.long(OPT_ISO_8601)
|
.long(OPT_ISO_8601)
|
||||||
.value_name("FMT")
|
.value_name("FMT")
|
||||||
|
.value_parser([DATE, HOUR, HOURS, MINUTE, MINUTES, SECOND, SECONDS, NS])
|
||||||
.help(ISO_8601_HELP_STRING),
|
.help(ISO_8601_HELP_STRING),
|
||||||
)
|
)
|
||||||
.arg(
|
.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]
|
#[test]
|
||||||
fn test_date_rfc_8601_second() {
|
fn test_date_rfc_8601_second() {
|
||||||
for param in ["--iso-8601", "--i"] {
|
for param in ["--iso-8601", "--i"] {
|
||||||
|
|
Loading…
Reference in a new issue