From 469abf24275c2e785cf3b453ba0e0a64e1afb362 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 19 Dec 2020 11:17:41 +0100 Subject: [PATCH] bug(seq) - Allow 'seq 6 -1 0' Was failing with ``` Found argument '-1' which wasn't expected, or isn't valid in this context ``` otherwise --- src/uu/seq/src/seq.rs | 4 +++- tests/by-util/test_seq.rs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index d531ffb12..d7fb2de48 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -8,7 +8,7 @@ extern crate clap; #[macro_use] extern crate uucore; -use clap::{App, Arg}; +use clap::{App, AppSettings, Arg}; use std::cmp; use std::io::{stdout, Write}; @@ -55,6 +55,7 @@ fn escape_sequences(s: &str) -> String { pub fn uumain(args: impl uucore::Args) -> i32 { let usage = get_usage(); let matches = App::new(executable!()) + .setting(AppSettings::AllowLeadingHyphen) .version(VERSION) .about(ABOUT) .usage(&usage[..]) @@ -84,6 +85,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { Arg::with_name(ARG_NUMBERS) .multiple(true) .takes_value(true) + .allow_hyphen_values(true) .max_values(3), ) .get_matches_from(args); diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index 9ee5c94aa..5e60ab5de 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -14,6 +14,10 @@ fn test_count_down() { .args(&["--", "5", "-1", "1"]) .run() .stdout_is("5\n4\n3\n2\n1\n"); + new_ucmd!() + .args(&["5", "-1", "1"]) + .run() + .stdout_is("5\n4\n3\n2\n1\n"); } #[test]