From a1f300e8a72cb8304cc29f246af54ebd4ea2f2cf Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sun, 27 Mar 2022 22:14:16 -0400 Subject: [PATCH] df: allow multiple occurrences of --output arg Allow multiple occurrences of the `--output` argument. For example, $ df --output=source --output=target | head -n1 Filesystem Mounted on --- src/uu/df/src/df.rs | 1 + tests/by-util/test_df.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/uu/df/src/df.rs b/src/uu/df/src/df.rs index 6dd5ad43d..ee2ea83a0 100644 --- a/src/uu/df/src/df.rs +++ b/src/uu/df/src/df.rs @@ -389,6 +389,7 @@ pub fn uu_app<'a>() -> Command<'a> { .long("output") .takes_value(true) .use_value_delimiter(true) + .multiple_occurrences(true) .possible_values(OUTPUT_FIELD_LIST) .default_missing_values(&OUTPUT_FIELD_LIST) .default_values(&["source", "size", "used", "avail", "pcent", "target"]) diff --git a/tests/by-util/test_df.rs b/tests/by-util/test_df.rs index 24277890d..4c87fc63e 100644 --- a/tests/by-util/test_df.rs +++ b/tests/by-util/test_df.rs @@ -222,6 +222,18 @@ fn test_output_selects_columns() { ); } +#[test] +fn test_output_multiple_occurrences() { + let output = new_ucmd!() + .args(&["--output=source", "--output=target"]) + .succeeds() + .stdout_move_str(); + assert_eq!( + output.lines().next().unwrap(), + "Filesystem Mounted on " + ); +} + // TODO Fix the spacing. #[test] fn test_output_file_all_filesystems() {