date: Added default value for date --i.

`default_missing_value` set to `OPT_DATE` (`"date"`)
`num_args(0..=1)` required for `default_missing_value`.

Using function name `test_date_rfc_8601_default`.
The function name `test_date_rfc_8601` is left intact for
compatibility.
 
Fixes: #4521
This commit is contained in:
Anish Bhobe 2023-03-16 18:50:08 +01:00
parent 5298ba8250
commit 624588d37f
2 changed files with 10 additions and 0 deletions

View file

@ -292,6 +292,8 @@ pub fn uu_app() -> Command {
.long(OPT_ISO_8601)
.value_name("FMT")
.value_parser([DATE, HOUR, HOURS, MINUTE, MINUTES, SECOND, SECONDS, NS])
.num_args(0..=1)
.default_missing_value(OPT_DATE)
.help(ISO_8601_HELP_STRING),
)
.arg(

View file

@ -43,6 +43,14 @@ fn test_date_rfc_3339() {
}
}
#[test]
fn test_date_rfc_8601_default() {
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}\n$").unwrap();
for param in ["--iso-8601", "--i"] {
new_ucmd!().arg(param).succeeds().stdout_matches(&re);
}
}
#[test]
fn test_date_rfc_8601() {
let re = Regex::new(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2},\d{9}[+-]\d{2}:\d{2}\n$").unwrap();