diff --git a/src/uu/shuf/Cargo.toml b/src/uu/shuf/Cargo.toml index 5ee75a249..30393276e 100644 --- a/src/uu/shuf/Cargo.toml +++ b/src/uu/shuf/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/shuf.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } rand = "0.5" uucore = { version=">=0.0.10", package="uucore", path="../../uucore" } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/shuf/src/shuf.rs b/src/uu/shuf/src/shuf.rs index ce0af5ec2..c1090e5ff 100644 --- a/src/uu/shuf/src/shuf.rs +++ b/src/uu/shuf/src/shuf.rs @@ -29,7 +29,7 @@ Write a random permutation of the input lines to standard output. With no FILE, or when FILE is -, read standard input. "#; -static TEMPLATE: &str = "Usage: {usage}\nMandatory arguments to long options are mandatory for short options too.\n{unified}"; +static TEMPLATE: &str = "Usage: {usage}\nMandatory arguments to long options are mandatory for short options too.\n{options}"; struct Options { head_count: usize, @@ -116,27 +116,27 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .name(NAME) .version(crate_version!()) - .template(TEMPLATE) - .usage(USAGE) + .help_template(TEMPLATE) + .override_usage(USAGE) .arg( - Arg::with_name(options::ECHO) - .short("e") + Arg::new(options::ECHO) + .short('e') .long(options::ECHO) .takes_value(true) .value_name("ARG") .help("treat each ARG as an input line") - .multiple(true) + .multiple_occurrences(true) .use_delimiter(false) .min_values(0) .conflicts_with(options::INPUT_RANGE), ) .arg( - Arg::with_name(options::INPUT_RANGE) - .short("i") + Arg::new(options::INPUT_RANGE) + .short('i') .long(options::INPUT_RANGE) .takes_value(true) .value_name("LO-HI") @@ -144,41 +144,41 @@ pub fn uu_app() -> App<'static, 'static> { .conflicts_with(options::FILE), ) .arg( - Arg::with_name(options::HEAD_COUNT) - .short("n") + Arg::new(options::HEAD_COUNT) + .short('n') .long(options::HEAD_COUNT) .takes_value(true) .value_name("COUNT") .help("output at most COUNT lines"), ) .arg( - Arg::with_name(options::OUTPUT) - .short("o") + Arg::new(options::OUTPUT) + .short('o') .long(options::OUTPUT) .takes_value(true) .value_name("FILE") .help("write result to FILE instead of standard output"), ) .arg( - Arg::with_name(options::RANDOM_SOURCE) + Arg::new(options::RANDOM_SOURCE) .long(options::RANDOM_SOURCE) .takes_value(true) .value_name("FILE") .help("get random bytes from FILE"), ) .arg( - Arg::with_name(options::REPEAT) - .short("r") + Arg::new(options::REPEAT) + .short('r') .long(options::REPEAT) .help("output lines can be repeated"), ) .arg( - Arg::with_name(options::ZERO_TERMINATED) - .short("z") + Arg::new(options::ZERO_TERMINATED) + .short('z') .long(options::ZERO_TERMINATED) .help("line delimiter is NUL, not newline"), ) - .arg(Arg::with_name(options::FILE).takes_value(true)) + .arg(Arg::new(options::FILE).takes_value(true)) } fn read_input_file(filename: &str) -> UResult> { diff --git a/tests/by-util/test_shuf.rs b/tests/by-util/test_shuf.rs index cbc01f8cd..901b6f8be 100644 --- a/tests/by-util/test_shuf.rs +++ b/tests/by-util/test_shuf.rs @@ -154,9 +154,7 @@ fn test_shuf_echo_and_input_range_not_allowed() { new_ucmd!() .args(&["-e", "0", "-i", "0-2"]) .fails() - .stderr_contains( - "The argument '--input-range ' cannot be used with '--echo ...'", - ); + .stderr_contains("cannot be used with"); } #[test] @@ -164,7 +162,7 @@ fn test_shuf_input_range_and_file_not_allowed() { new_ucmd!() .args(&["-i", "0-9", "file"]) .fails() - .stderr_contains("The argument '' cannot be used with '--input-range '"); + .stderr_contains("cannot be used with"); } #[test]