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

rmdir: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 14:41:24 +01:00
parent 283973c5bf
commit f260f60093
2 changed files with 13 additions and 17 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/rmdir.rs" path = "src/rmdir.rs"
[dependencies] [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 = { version=">=0.0.10", package="uucore", path="../../uucore" }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
libc = "0.2.42" libc = "0.2.42"

View file

@ -33,7 +33,7 @@ fn usage() -> String {
pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage(); let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let opts = Opts { let opts = Opts {
ignore: matches.is_present(OPT_IGNORE_FAIL_NON_EMPTY), ignore: matches.is_present(OPT_IGNORE_FAIL_NON_EMPTY),
@ -175,35 +175,31 @@ struct Opts {
verbose: bool, verbose: bool,
} }
pub fn uu_app() -> App<'static, 'static> { pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name()) App::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.arg( .arg(
Arg::with_name(OPT_IGNORE_FAIL_NON_EMPTY) Arg::new(OPT_IGNORE_FAIL_NON_EMPTY)
.long(OPT_IGNORE_FAIL_NON_EMPTY) .long(OPT_IGNORE_FAIL_NON_EMPTY)
.help("ignore each failure that is solely because a directory is non-empty"), .help("ignore each failure that is solely because a directory is non-empty"),
) )
.arg( .arg(Arg::new(OPT_PARENTS).short('p').long(OPT_PARENTS).help(
Arg::with_name(OPT_PARENTS) "remove DIRECTORY and its ancestors; e.g.,
.short("p")
.long(OPT_PARENTS)
.help(
"remove DIRECTORY and its ancestors; e.g.,
'rmdir -p a/b/c' is similar to rmdir a/b/c a/b a", 'rmdir -p a/b/c' is similar to rmdir a/b/c a/b a",
), ))
)
.arg( .arg(
Arg::with_name(OPT_VERBOSE) Arg::new(OPT_VERBOSE)
.short("v") .short('v')
.long(OPT_VERBOSE) .long(OPT_VERBOSE)
.help("output a diagnostic for every directory processed"), .help("output a diagnostic for every directory processed"),
) )
.arg( .arg(
Arg::with_name(ARG_DIRS) Arg::new(ARG_DIRS)
.multiple(true) .multiple_occurrences(true)
.takes_value(true) .takes_value(true)
.min_values(1) .min_values(1)
.required(true), .required(true)
.allow_invalid_utf8(true),
) )
} }