From 60d51910e6de390b45648003a43de9f1d10477ca Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 1 Oct 2022 12:02:29 +0200 Subject: [PATCH] users: update to clap 4 --- src/uu/users/Cargo.toml | 2 +- src/uu/users/src/users.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/uu/users/Cargo.toml b/src/uu/users/Cargo.toml index 167d2b866..101af11e3 100644 --- a/src/uu/users/Cargo.toml +++ b/src/uu/users/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" path = "src/users.rs" [dependencies] -clap = { version = "3.2", features = ["wrap_help", "cargo"] } +clap = { version = "4.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["utmpx"] } [[bin]] diff --git a/src/uu/users/src/users.rs b/src/uu/users/src/users.rs index f8067bcc6..b812bfea1 100644 --- a/src/uu/users/src/users.rs +++ b/src/uu/users/src/users.rs @@ -11,6 +11,7 @@ use std::ffi::OsString; use std::path::Path; +use clap::builder::ValueParser; use clap::{crate_version, Arg, Command}; use uucore::error::UResult; use uucore::format_usage; @@ -31,10 +32,8 @@ If FILE is not specified, use {}. /var/log/wtmp as FILE is common.", #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let after_help = get_long_usage(); - let matches = uu_app() - .after_help(&after_help[..]) + .after_help(get_long_usage()) .try_get_matches_from(args)?; let files: Vec<&Path> = matches @@ -61,7 +60,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app<'a>() -> Command<'a> { +pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) @@ -69,8 +68,8 @@ pub fn uu_app<'a>() -> Command<'a> { .infer_long_args(true) .arg( Arg::new(ARG_FILES) - .takes_value(true) - .max_values(1) - .value_hint(clap::ValueHint::FilePath), + .num_args(1) + .value_hint(clap::ValueHint::FilePath) + .value_parser(ValueParser::os_string()), ) }