mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
rmdir: update to clap 4
This commit is contained in:
parent
c228556791
commit
634a4aab8e
2 changed files with 21 additions and 15 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/rmdir.rs"
|
path = "src/rmdir.rs"
|
||||||
|
|
||||||
[dependencies]
|
[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"] }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["fs"] }
|
||||||
libc = "0.2.135"
|
libc = "0.2.135"
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
extern crate uucore;
|
extern crate uucore;
|
||||||
|
|
||||||
use clap::builder::ValueParser;
|
use clap::builder::ValueParser;
|
||||||
use clap::{crate_version, Arg, Command};
|
use clap::{crate_version, Arg, ArgAction, Command};
|
||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
use std::fs::{read_dir, remove_dir};
|
use std::fs::{read_dir, remove_dir};
|
||||||
use std::io;
|
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 matches = uu_app().try_get_matches_from(args)?;
|
||||||
|
|
||||||
let opts = Opts {
|
let opts = Opts {
|
||||||
ignore: matches.contains_id(OPT_IGNORE_FAIL_NON_EMPTY),
|
ignore: matches.get_flag(OPT_IGNORE_FAIL_NON_EMPTY),
|
||||||
parents: matches.contains_id(OPT_PARENTS),
|
parents: matches.get_flag(OPT_PARENTS),
|
||||||
verbose: matches.contains_id(OPT_VERBOSE),
|
verbose: matches.get_flag(OPT_VERBOSE),
|
||||||
};
|
};
|
||||||
|
|
||||||
for path in matches
|
for path in matches
|
||||||
|
@ -167,7 +167,7 @@ struct Opts {
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -176,24 +176,30 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(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")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(Arg::new(OPT_PARENTS).short('p').long(OPT_PARENTS).help(
|
.arg(
|
||||||
"remove DIRECTORY and its ancestors; e.g.,
|
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",
|
'rmdir -p a/b/c' is similar to rmdir a/b/c a/b a",
|
||||||
))
|
)
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(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")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(ARG_DIRS)
|
Arg::new(ARG_DIRS)
|
||||||
.multiple_occurrences(true)
|
.action(ArgAction::Append)
|
||||||
.takes_value(true)
|
.num_args(1..)
|
||||||
.min_values(1)
|
|
||||||
.required(true)
|
|
||||||
.value_parser(ValueParser::os_string())
|
.value_parser(ValueParser::os_string())
|
||||||
.value_hint(clap::ValueHint::DirPath),
|
.value_hint(clap::ValueHint::DirPath),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue