From 63c936af2acf657ea995d1fcfe1f98cc7b4e5681 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Fri, 7 Nov 2025 23:25:57 +0100 Subject: [PATCH] date: add --uct alias and allow multiple option aliases together fix tests/misc/option-aliases.sh --- src/uu/date/src/date.rs | 3 +++ tests/by-util/test_date.rs | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/uu/date/src/date.rs b/src/uu/date/src/date.rs index e6e57c6785e..5321256007d 100644 --- a/src/uu/date/src/date.rs +++ b/src/uu/date/src/date.rs @@ -460,6 +460,7 @@ pub fn uu_app() -> Command { .long(OPT_RFC_EMAIL) .alias(OPT_RFC_2822) .alias(OPT_RFC_822) + .overrides_with(OPT_RFC_EMAIL) .help(translate!("date-help-rfc-email")) .action(ArgAction::SetTrue), ) @@ -510,6 +511,8 @@ pub fn uu_app() -> Command { .short('u') .long(OPT_UNIVERSAL) .visible_alias(OPT_UNIVERSAL_2) + .alias("uct") + .overrides_with(OPT_UNIVERSAL) .help(translate!("date-help-universal")) .action(ArgAction::SetTrue), ) diff --git a/tests/by-util/test_date.rs b/tests/by-util/test_date.rs index 372e9193770..9d59efd58a7 100644 --- a/tests/by-util/test_date.rs +++ b/tests/by-util/test_date.rs @@ -24,6 +24,17 @@ fn test_date_email() { } } +#[test] +fn test_date_email_multiple_aliases() { + // Test that multiple RFC email aliases can be used together + // This matches GNU behavior where all aliases map to the same option + new_ucmd!() + .arg("--rfc-email") + .arg("--rfc-822") + .arg("--rfc-2822") + .succeeds(); +} + #[test] fn test_date_rfc_3339() { let scene = TestScenario::new(util_name!()); @@ -141,11 +152,22 @@ fn test_date_rfc_8601_date() { #[test] fn test_date_utc() { - for param in ["--universal", "--utc", "--uni", "--u"] { + for param in ["--universal", "--utc", "--uct", "--uni", "--u"] { new_ucmd!().arg(param).succeeds(); } } +#[test] +fn test_date_utc_multiple_aliases() { + // Test that multiple UTC aliases can be used together + // This matches GNU behavior where all aliases map to the same option + new_ucmd!() + .arg("--uct") + .arg("--utc") + .arg("--universal") + .succeeds(); +} + #[test] fn test_date_utc_issue_6495() { new_ucmd!()