From 864c66646760f3f2d4f5880d092191c4ca01ef12 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Wed, 1 Jun 2022 16:18:57 +0200 Subject: [PATCH] expand: allow multiple "tabs" args --- src/uu/expand/src/expand.rs | 5 +++-- tests/by-util/test_expand.rs | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/uu/expand/src/expand.rs b/src/uu/expand/src/expand.rs index ff39ff6cc75..1700920d381 100644 --- a/src/uu/expand/src/expand.rs +++ b/src/uu/expand/src/expand.rs @@ -132,8 +132,8 @@ struct Options { impl Options { fn new(matches: &ArgMatches) -> Self { - let (remaining_mode, tabstops) = match matches.value_of(options::TABS) { - Some(s) => tabstops_parse(s), + let (remaining_mode, tabstops) = match matches.values_of(options::TABS) { + Some(s) => tabstops_parse(&s.collect::>().join(",")), None => (RemainingMode::None, vec![DEFAULT_TABSTOP]), }; @@ -195,6 +195,7 @@ pub fn uu_app<'a>() -> Command<'a> { .short('t') .value_name("N, LIST") .takes_value(true) + .multiple_occurrences(true) .help("have tabs N characters apart, not 8 or use comma separated list of explicit tab positions"), ) .arg( diff --git a/tests/by-util/test_expand.rs b/tests/by-util/test_expand.rs index 9c06fe904fe..4566e4176b6 100644 --- a/tests/by-util/test_expand.rs +++ b/tests/by-util/test_expand.rs @@ -73,6 +73,15 @@ fn test_tabs_mixed_style_list() { .stdout_is("a b c d e"); } +#[test] +fn test_multiple_tabs_args() { + new_ucmd!() + .args(&["--tabs=3", "--tabs=6", "--tabs=9"]) + .pipe_in("a\tb\tc\td\te") + .succeeds() + .stdout_is("a b c d e"); +} + #[test] fn test_tabs_empty_string() { new_ucmd!()