From bd22aba03b5617c4dec93dd5950fd75fe47ff780 Mon Sep 17 00:00:00 2001 From: Yykz Date: Mon, 18 Dec 2023 12:47:37 +0100 Subject: [PATCH 1/3] make args of wc overriding --- src/uu/wc/src/wc.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uu/wc/src/wc.rs b/src/uu/wc/src/wc.rs index 83081124d..d69647c38 100644 --- a/src/uu/wc/src/wc.rs +++ b/src/uu/wc/src/wc.rs @@ -395,6 +395,7 @@ pub fn uu_app() -> Command { .about(ABOUT) .override_usage(format_usage(USAGE)) .infer_long_args(true) + .args_override_self(true) .arg( Arg::new(options::BYTES) .short('c') From cae113c23757665262c7853c0fe8f0772b132203 Mon Sep 17 00:00:00 2001 From: Yykz Date: Mon, 18 Dec 2023 14:12:59 +0100 Subject: [PATCH 2/3] Added tests --- tests/by-util/test_wc.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/by-util/test_wc.rs b/tests/by-util/test_wc.rs index 9c55bd3bc..df2551555 100644 --- a/tests/by-util/test_wc.rs +++ b/tests/by-util/test_wc.rs @@ -725,3 +725,16 @@ fn files0_from_dir() { .fails() .stderr_only(dir_err!("-")); } + +#[test] +fn test_args_override() { + new_ucmd!() + .args(&["-ll", "-l", "alice_in_wonderland.txt"]) + .run() + .stdout_is("5 alice_in_wonderland.txt\n"); + + new_ucmd!() + .args(&["--total=always", "--total=never", "alice_in_wonderland.txt"]) + .run() + .stdout_is(" 5 57 302 alice_in_wonderland.txt\n"); +} \ No newline at end of file From 652e02fb59ba948cf35ab3bc04fa942fb643c83a Mon Sep 17 00:00:00 2001 From: Yykz Date: Mon, 18 Dec 2023 15:34:51 +0100 Subject: [PATCH 3/3] cargo fmt --- tests/by-util/test_wc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_wc.rs b/tests/by-util/test_wc.rs index df2551555..77716e43a 100644 --- a/tests/by-util/test_wc.rs +++ b/tests/by-util/test_wc.rs @@ -737,4 +737,4 @@ fn test_args_override() { .args(&["--total=always", "--total=never", "alice_in_wonderland.txt"]) .run() .stdout_is(" 5 57 302 alice_in_wonderland.txt\n"); -} \ No newline at end of file +}