From a2023c8d154c5facdedbd96086283267c1c0f6ba Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 29 Sep 2022 23:26:47 +0200 Subject: [PATCH] pahtchk: update to clap 4 --- src/uu/pathchk/Cargo.toml | 2 +- src/uu/pathchk/src/pathchk.rs | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/uu/pathchk/Cargo.toml b/src/uu/pathchk/Cargo.toml index 39259b684..b25450b89 100644 --- a/src/uu/pathchk/Cargo.toml +++ b/src/uu/pathchk/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" path = "src/pathchk.rs" [dependencies] -clap = { version = "3.2", features = ["wrap_help", "cargo"] } +clap = { version = "4.0", features = ["wrap_help", "cargo"] } libc = "0.2.135" uucore = { version=">=0.0.16", package="uucore", path="../../uucore" } diff --git a/src/uu/pathchk/src/pathchk.rs b/src/uu/pathchk/src/pathchk.rs index 1c0444ac7..626596ab0 100644 --- a/src/uu/pathchk/src/pathchk.rs +++ b/src/uu/pathchk/src/pathchk.rs @@ -8,7 +8,7 @@ // * that was distributed with this source code. // spell-checker:ignore (ToDO) lstat -use clap::{crate_version, Arg, Command}; +use clap::{crate_version, Arg, ArgAction, Command}; use std::fs; use std::io::{ErrorKind, Write}; use uucore::display::Quotable; @@ -44,9 +44,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().try_get_matches_from(args)?; // set working mode - let is_posix = matches.get_many::(options::POSIX).is_some(); - let is_posix_special = matches.get_many::(options::POSIX_SPECIAL).is_some(); - let is_portability = matches.get_many::(options::PORTABILITY).is_some(); + let is_posix = matches.get_flag(options::POSIX); + let is_posix_special = matches.get_flag(options::POSIX_SPECIAL); + let is_portability = matches.get_flag(options::PORTABILITY); let mode = if (is_posix && is_posix_special) || is_portability { Mode::Both @@ -82,7 +82,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) @@ -91,22 +91,25 @@ pub fn uu_app<'a>() -> Command<'a> { .arg( Arg::new(options::POSIX) .short('p') - .help("check for most POSIX systems"), + .help("check for most POSIX systems") + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::POSIX_SPECIAL) .short('P') - .help(r#"check for empty names and leading "-""#), + .help(r#"check for empty names and leading "-""#) + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::PORTABILITY) .long(options::PORTABILITY) - .help("check for all POSIX systems (equivalent to -p -P)"), + .help("check for all POSIX systems (equivalent to -p -P)") + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::PATH) .hide(true) - .multiple_occurrences(true) + .action(ArgAction::Append) .value_hint(clap::ValueHint::AnyPath), ) }