1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-17 04:06:18 +00:00

pahtchk: update to clap 4

This commit is contained in:
Terts Diepraam 2022-09-29 23:26:47 +02:00
parent e346253a30
commit a2023c8d15
2 changed files with 13 additions and 10 deletions

View file

@ -15,7 +15,7 @@ edition = "2021"
path = "src/pathchk.rs" path = "src/pathchk.rs"
[dependencies] [dependencies]
clap = { version = "3.2", features = ["wrap_help", "cargo"] } clap = { version = "4.0", features = ["wrap_help", "cargo"] }
libc = "0.2.135" libc = "0.2.135"
uucore = { version=">=0.0.16", package="uucore", path="../../uucore" } uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }

View file

@ -8,7 +8,7 @@
// * that was distributed with this source code. // * that was distributed with this source code.
// spell-checker:ignore (ToDO) lstat // spell-checker:ignore (ToDO) lstat
use clap::{crate_version, Arg, Command}; use clap::{crate_version, Arg, ArgAction, Command};
use std::fs; use std::fs;
use std::io::{ErrorKind, Write}; use std::io::{ErrorKind, Write};
use uucore::display::Quotable; 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)?; let matches = uu_app().try_get_matches_from(args)?;
// set working mode // set working mode
let is_posix = matches.get_many::<String>(options::POSIX).is_some(); let is_posix = matches.get_flag(options::POSIX);
let is_posix_special = matches.get_many::<String>(options::POSIX_SPECIAL).is_some(); let is_posix_special = matches.get_flag(options::POSIX_SPECIAL);
let is_portability = matches.get_many::<String>(options::PORTABILITY).is_some(); let is_portability = matches.get_flag(options::PORTABILITY);
let mode = if (is_posix && is_posix_special) || is_portability { let mode = if (is_posix && is_posix_special) || is_portability {
Mode::Both Mode::Both
@ -82,7 +82,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
pub fn uu_app<'a>() -> Command<'a> { pub fn uu_app() -> Command {
Command::new(uucore::util_name()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
@ -91,22 +91,25 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg( .arg(
Arg::new(options::POSIX) Arg::new(options::POSIX)
.short('p') .short('p')
.help("check for most POSIX systems"), .help("check for most POSIX systems")
.action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::POSIX_SPECIAL) Arg::new(options::POSIX_SPECIAL)
.short('P') .short('P')
.help(r#"check for empty names and leading "-""#), .help(r#"check for empty names and leading "-""#)
.action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::PORTABILITY) Arg::new(options::PORTABILITY)
.long(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(
Arg::new(options::PATH) Arg::new(options::PATH)
.hide(true) .hide(true)
.multiple_occurrences(true) .action(ArgAction::Append)
.value_hint(clap::ValueHint::AnyPath), .value_hint(clap::ValueHint::AnyPath),
) )
} }