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

rmdir: update to clap 4

This commit is contained in:
Terts Diepraam 2022-09-30 16:25:19 +02:00
parent c228556791
commit 634a4aab8e
2 changed files with 21 additions and 15 deletions

View file

@ -15,7 +15,7 @@ edition = "2021"
path = "src/rmdir.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=["fs"] }
libc = "0.2.135"

View file

@ -11,7 +11,7 @@
extern crate uucore;
use clap::builder::ValueParser;
use clap::{crate_version, Arg, Command};
use clap::{crate_version, Arg, ArgAction, Command};
use std::ffi::OsString;
use std::fs::{read_dir, remove_dir};
use std::io;
@ -34,9 +34,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app().try_get_matches_from(args)?;
let opts = Opts {
ignore: matches.contains_id(OPT_IGNORE_FAIL_NON_EMPTY),
parents: matches.contains_id(OPT_PARENTS),
verbose: matches.contains_id(OPT_VERBOSE),
ignore: matches.get_flag(OPT_IGNORE_FAIL_NON_EMPTY),
parents: matches.get_flag(OPT_PARENTS),
verbose: matches.get_flag(OPT_VERBOSE),
};
for path in matches
@ -167,7 +167,7 @@ struct Opts {
verbose: bool,
}
pub fn uu_app<'a>() -> Command<'a> {
pub fn uu_app() -> Command {
Command::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
@ -176,24 +176,30 @@ pub fn uu_app<'a>() -> Command<'a> {
.arg(
Arg::new(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")
.action(ArgAction::SetTrue),
)
.arg(Arg::new(OPT_PARENTS).short('p').long(OPT_PARENTS).help(
"remove DIRECTORY and its ancestors; e.g.,
.arg(
Arg::new(OPT_PARENTS)
.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",
))
)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(OPT_VERBOSE)
.short('v')
.long(OPT_VERBOSE)
.help("output a diagnostic for every directory processed"),
.help("output a diagnostic for every directory processed")
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(ARG_DIRS)
.multiple_occurrences(true)
.takes_value(true)
.min_values(1)
.required(true)
.action(ArgAction::Append)
.num_args(1..)
.value_parser(ValueParser::os_string())
.value_hint(clap::ValueHint::DirPath),
)