From e3b8e6c993311d0a08f7ad9b39a75d6b0a8e965b Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 11 Jan 2022 15:22:12 +0100 Subject: [PATCH] who: clap 3 --- src/uu/who/Cargo.toml | 2 +- src/uu/who/src/who.rs | 64 +++++++++++++++++++-------------------- tests/by-util/test_who.rs | 2 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/uu/who/Cargo.toml b/src/uu/who/Cargo.toml index 588306927..6b9e7d9a9 100644 --- a/src/uu/who/Cargo.toml +++ b/src/uu/who/Cargo.toml @@ -17,7 +17,7 @@ path = "src/who.rs" [dependencies] uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["utmpx"] } 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 = "who" diff --git a/src/uu/who/src/who.rs b/src/uu/who/src/who.rs index 14f39536d..0428be048 100644 --- a/src/uu/who/src/who.rs +++ b/src/uu/who/src/who.rs @@ -69,7 +69,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); @@ -161,101 +161,101 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { who.exec() } -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::ALL) + Arg::new(options::ALL) .long(options::ALL) - .short("a") + .short('a') .help("same as -b -d --login -p -r -t -T -u"), ) .arg( - Arg::with_name(options::BOOT) + Arg::new(options::BOOT) .long(options::BOOT) - .short("b") + .short('b') .help("time of last system boot"), ) .arg( - Arg::with_name(options::DEAD) + Arg::new(options::DEAD) .long(options::DEAD) - .short("d") + .short('d') .help("print dead processes"), ) .arg( - Arg::with_name(options::HEADING) + Arg::new(options::HEADING) .long(options::HEADING) - .short("H") + .short('H') .help("print line of column headings"), ) .arg( - Arg::with_name(options::LOGIN) + Arg::new(options::LOGIN) .long(options::LOGIN) - .short("l") + .short('l') .help("print system login processes"), ) .arg( - Arg::with_name(options::LOOKUP) + Arg::new(options::LOOKUP) .long(options::LOOKUP) .help("attempt to canonicalize hostnames via DNS"), ) .arg( - Arg::with_name(options::ONLY_HOSTNAME_USER) - .short("m") + Arg::new(options::ONLY_HOSTNAME_USER) + .short('m') .help("only hostname and user associated with stdin"), ) .arg( - Arg::with_name(options::PROCESS) + Arg::new(options::PROCESS) .long(options::PROCESS) - .short("p") + .short('p') .help("print active processes spawned by init"), ) .arg( - Arg::with_name(options::COUNT) + Arg::new(options::COUNT) .long(options::COUNT) - .short("q") + .short('q') .help("all login names and number of users logged on"), ) .arg( - Arg::with_name(options::RUNLEVEL) + Arg::new(options::RUNLEVEL) .long(options::RUNLEVEL) - .short("r") + .short('r') .help(RUNLEVEL_HELP), ) .arg( - Arg::with_name(options::SHORT) + Arg::new(options::SHORT) .long(options::SHORT) - .short("s") + .short('s') .help("print only name, line, and time (default)"), ) .arg( - Arg::with_name(options::TIME) + Arg::new(options::TIME) .long(options::TIME) - .short("t") + .short('t') .help("print last system clock change"), ) .arg( - Arg::with_name(options::USERS) + Arg::new(options::USERS) .long(options::USERS) - .short("u") + .short('u') .help("list users logged in"), ) .arg( - Arg::with_name(options::MESG) + Arg::new(options::MESG) .long(options::MESG) - .short("T") + .short('T') // .visible_short_alias('w') // TODO: requires clap "3.0.0-beta.2" .visible_aliases(&["message", "writable"]) .help("add user's message status as +, - or ?"), ) .arg( - Arg::with_name("w") // work around for `Arg::visible_short_alias` - .short("w") + Arg::new("w") // work around for `Arg::visible_short_alias` + .short('w') .help("same as -T"), ) .arg( - Arg::with_name(options::FILE) + Arg::new(options::FILE) .takes_value(true) .min_values(1) .max_values(2), diff --git a/tests/by-util/test_who.rs b/tests/by-util/test_who.rs index d05715517..d91026903 100644 --- a/tests/by-util/test_who.rs +++ b/tests/by-util/test_who.rs @@ -136,7 +136,7 @@ fn test_arg1_arg2() { #[test] fn test_too_many_args() { const EXPECTED: &str = - "error: The value 'u' was provided to '...', but it wasn't expecting any more values"; + "error: The value 'u' was provided to '...' but it wasn't expecting any more values"; let args = ["am", "i", "u"]; new_ucmd!().args(&args).fails().stderr_contains(EXPECTED);