date: add --uct alias and allow multiple option aliases together

fix tests/misc/option-aliases.sh
This commit is contained in:
Sylvestre Ledru 2025-11-07 23:25:57 +01:00
parent b2d0773356
commit 63c936af2a
2 changed files with 26 additions and 1 deletions

View file

@ -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),
)

View file

@ -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!()