From c39a9b49d456051e1a5c4288df9ece351b032283 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 11 Jan 2022 14:24:54 +0100 Subject: [PATCH] pinky: clap 3 --- src/uu/pinky/Cargo.toml | 2 +- src/uu/pinky/src/pinky.rs | 44 ++++++++++++++++++------------------- tests/by-util/test_pinky.rs | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/uu/pinky/Cargo.toml b/src/uu/pinky/Cargo.toml index a4915e9f3..b81b8f33d 100644 --- a/src/uu/pinky/Cargo.toml +++ b/src/uu/pinky/Cargo.toml @@ -17,7 +17,7 @@ path = "src/pinky.rs" [dependencies] uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["utmpx", "entries"] } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } [[bin]] name = "pinky" diff --git a/src/uu/pinky/src/pinky.rs b/src/uu/pinky/src/pinky.rs index 8220affc5..d3b38073f 100644 --- a/src/uu/pinky/src/pinky.rs +++ b/src/uu/pinky/src/pinky.rs @@ -61,7 +61,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let after_help = get_long_usage(); let matches = uu_app() - .usage(&usage[..]) + .override_usage(&usage[..]) .after_help(&after_help[..]) .get_matches_from(args); @@ -132,60 +132,60 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::LONG_FORMAT) - .short("l") + Arg::new(options::LONG_FORMAT) + .short('l') .requires(options::USER) .help("produce long format output for the specified USERs"), ) .arg( - Arg::with_name(options::OMIT_HOME_DIR) - .short("b") + Arg::new(options::OMIT_HOME_DIR) + .short('b') .help("omit the user's home directory and shell in long format"), ) .arg( - Arg::with_name(options::OMIT_PROJECT_FILE) - .short("h") + Arg::new(options::OMIT_PROJECT_FILE) + .short('h') .help("omit the user's project file in long format"), ) .arg( - Arg::with_name(options::OMIT_PLAN_FILE) - .short("p") + Arg::new(options::OMIT_PLAN_FILE) + .short('p') .help("omit the user's plan file in long format"), ) .arg( - Arg::with_name(options::SHORT_FORMAT) - .short("s") + Arg::new(options::SHORT_FORMAT) + .short('s') .help("do short format output, this is the default"), ) .arg( - Arg::with_name(options::OMIT_HEADINGS) - .short("f") + Arg::new(options::OMIT_HEADINGS) + .short('f') .help("omit the line of column headings in short format"), ) .arg( - Arg::with_name(options::OMIT_NAME) - .short("w") + Arg::new(options::OMIT_NAME) + .short('w') .help("omit the user's full name in short format"), ) .arg( - Arg::with_name(options::OMIT_NAME_HOST) - .short("i") + Arg::new(options::OMIT_NAME_HOST) + .short('i') .help("omit the user's full name and remote host in short format"), ) .arg( - Arg::with_name(options::OMIT_NAME_HOST_TIME) - .short("q") + Arg::new(options::OMIT_NAME_HOST_TIME) + .short('q') .help("omit the user's full name, remote host and idle time in short format"), ) .arg( - Arg::with_name(options::USER) + Arg::new(options::USER) .takes_value(true) - .multiple(true), + .multiple_occurrences(true), ) } diff --git a/tests/by-util/test_pinky.rs b/tests/by-util/test_pinky.rs index 17cec1b4b..05525e927 100644 --- a/tests/by-util/test_pinky.rs +++ b/tests/by-util/test_pinky.rs @@ -58,7 +58,7 @@ fn test_long_format_multiple_users() { #[test] fn test_long_format_wo_user() { // "no username specified; at least one must be specified when using -l" - new_ucmd!().arg("-l").fails().code_is(1); + new_ucmd!().arg("-l").fails(); } #[cfg(unix)]