1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

pathchk: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 14:24:16 +01:00
parent 8f7f3d18ee
commit 49b19972cc
2 changed files with 13 additions and 9 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/pathchk.rs"
[dependencies]
clap = { version = "2.33", features = ["wrap_help"] }
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }

View file

@ -47,7 +47,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.collect_str(InvalidEncodingHandling::ConvertLossy)
.accept_any();
let matches = uu_app().usage(&usage[..]).get_matches_from(args);
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
// set working mode
let is_posix = matches.values_of(options::POSIX).is_some();
@ -88,26 +88,30 @@ 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(ABOUT)
.arg(
Arg::with_name(options::POSIX)
.short("p")
Arg::new(options::POSIX)
.short('p')
.help("check for most POSIX systems"),
)
.arg(
Arg::with_name(options::POSIX_SPECIAL)
.short("P")
Arg::new(options::POSIX_SPECIAL)
.short('P')
.help(r#"check for empty names and leading "-""#),
)
.arg(
Arg::with_name(options::PORTABILITY)
Arg::new(options::PORTABILITY)
.long(options::PORTABILITY)
.help("check for all POSIX systems (equivalent to -p -P)"),
)
.arg(Arg::with_name(options::PATH).hidden(true).multiple(true))
.arg(
Arg::new(options::PATH)
.hide(true)
.multiple_occurrences(true),
)
}
// check a path, given as a slice of it's components and an operating mode