mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
expand: allow multiple "tabs" args
This commit is contained in:
parent
2ed64fc9a1
commit
864c666467
2 changed files with 12 additions and 2 deletions
|
@ -132,8 +132,8 @@ struct Options {
|
||||||
|
|
||||||
impl Options {
|
impl Options {
|
||||||
fn new(matches: &ArgMatches) -> Self {
|
fn new(matches: &ArgMatches) -> Self {
|
||||||
let (remaining_mode, tabstops) = match matches.value_of(options::TABS) {
|
let (remaining_mode, tabstops) = match matches.values_of(options::TABS) {
|
||||||
Some(s) => tabstops_parse(s),
|
Some(s) => tabstops_parse(&s.collect::<Vec<&str>>().join(",")),
|
||||||
None => (RemainingMode::None, vec![DEFAULT_TABSTOP]),
|
None => (RemainingMode::None, vec![DEFAULT_TABSTOP]),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,6 +195,7 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.short('t')
|
.short('t')
|
||||||
.value_name("N, LIST")
|
.value_name("N, LIST")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
|
.multiple_occurrences(true)
|
||||||
.help("have tabs N characters apart, not 8 or use comma separated list of explicit tab positions"),
|
.help("have tabs N characters apart, not 8 or use comma separated list of explicit tab positions"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
|
|
@ -73,6 +73,15 @@ fn test_tabs_mixed_style_list() {
|
||||||
.stdout_is("a b c d e");
|
.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]
|
#[test]
|
||||||
fn test_tabs_empty_string() {
|
fn test_tabs_empty_string() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue