From 67e5ede0a17c44786bd48a4b186d42ab19fd20bb Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 11 Jan 2022 12:15:31 +0100 Subject: [PATCH] basename: clap 3 --- src/uu/basename/Cargo.toml | 2 +- src/uu/basename/src/basename.rs | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/uu/basename/Cargo.toml b/src/uu/basename/Cargo.toml index ed2ff834b..6096f7b29 100644 --- a/src/uu/basename/Cargo.toml +++ b/src/uu/basename/Cargo.toml @@ -15,7 +15,7 @@ edition = "2018" path = "src/basename.rs" [dependencies] -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } 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/basename/src/basename.rs b/src/uu/basename/src/basename.rs index 9f3ce3cc4..94c7e43e4 100644 --- a/src/uu/basename/src/basename.rs +++ b/src/uu/basename/src/basename.rs @@ -40,7 +40,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { // // Argument parsing // - let matches = uu_app().usage(&usage[..]).get_matches_from(args); + let matches = uu_app().override_usage(&usage[..]).get_matches_from(args); // too few arguments if !matches.is_present(options::NAME) { @@ -93,27 +93,31 @@ 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()) .version(crate_version!()) .about(SUMMARY) .arg( - Arg::with_name(options::MULTIPLE) - .short("a") + Arg::new(options::MULTIPLE) + .short('a') .long(options::MULTIPLE) .help("support multiple arguments and treat each as a NAME"), ) - .arg(Arg::with_name(options::NAME).multiple(true).hidden(true)) .arg( - Arg::with_name(options::SUFFIX) - .short("s") + Arg::new(options::NAME) + .multiple_occurrences(true) + .hide(true), + ) + .arg( + Arg::new(options::SUFFIX) + .short('s') .long(options::SUFFIX) .value_name("SUFFIX") .help("remove a trailing SUFFIX; implies -a"), ) .arg( - Arg::with_name(options::ZERO) - .short("z") + Arg::new(options::ZERO) + .short('z') .long(options::ZERO) .help("end each output line with NUL, not newline"), )