mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-31 13:07:46 +00:00
chown: update to clap 4
This commit is contained in:
parent
075245235e
commit
624700f835
2 changed files with 31 additions and 17 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/chown.rs"
|
path = "src/chown.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=["entries", "fs", "perms"] }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["entries", "fs", "perms"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
|
|
|
@ -14,7 +14,7 @@ use uucore::perms::{chown_base, options, IfFrom};
|
||||||
|
|
||||||
use uucore::error::{FromIo, UResult, USimpleError};
|
use uucore::error::{FromIo, UResult, USimpleError};
|
||||||
|
|
||||||
use clap::{crate_version, Arg, ArgMatches, Command};
|
use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
|
@ -63,22 +63,25 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
.override_usage(format_usage(USAGE))
|
.override_usage(format_usage(USAGE))
|
||||||
.infer_long_args(true)
|
.infer_long_args(true)
|
||||||
|
.disable_help_flag(true)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::HELP)
|
Arg::new(options::HELP)
|
||||||
.long(options::HELP)
|
.long(options::HELP)
|
||||||
.help("Print help information."),
|
.help("Print help information.")
|
||||||
|
.action(ArgAction::Help),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::verbosity::CHANGES)
|
Arg::new(options::verbosity::CHANGES)
|
||||||
.short('c')
|
.short('c')
|
||||||
.long(options::verbosity::CHANGES)
|
.long(options::verbosity::CHANGES)
|
||||||
.help("like verbose but report only when a change is made"),
|
.help("like verbose but report only when a change is made")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::dereference::DEREFERENCE)
|
Arg::new(options::dereference::DEREFERENCE)
|
||||||
|
@ -86,7 +89,8 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.help(
|
.help(
|
||||||
"affect the referent of each symbolic link (this is the default), \
|
"affect the referent of each symbolic link (this is the default), \
|
||||||
rather than the symbolic link itself",
|
rather than the symbolic link itself",
|
||||||
),
|
)
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::dereference::NO_DEREFERENCE)
|
Arg::new(options::dereference::NO_DEREFERENCE)
|
||||||
|
@ -95,7 +99,8 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.help(
|
.help(
|
||||||
"affect symbolic links instead of any referenced file \
|
"affect symbolic links instead of any referenced file \
|
||||||
(useful only on systems that can change the ownership of a symlink)",
|
(useful only on systems that can change the ownership of a symlink)",
|
||||||
),
|
)
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FROM)
|
Arg::new(options::FROM)
|
||||||
|
@ -111,23 +116,27 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::preserve_root::PRESERVE)
|
Arg::new(options::preserve_root::PRESERVE)
|
||||||
.long(options::preserve_root::PRESERVE)
|
.long(options::preserve_root::PRESERVE)
|
||||||
.help("fail to operate recursively on '/'"),
|
.help("fail to operate recursively on '/'")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::preserve_root::NO_PRESERVE)
|
Arg::new(options::preserve_root::NO_PRESERVE)
|
||||||
.long(options::preserve_root::NO_PRESERVE)
|
.long(options::preserve_root::NO_PRESERVE)
|
||||||
.help("do not treat '/' specially (the default)"),
|
.help("do not treat '/' specially (the default)")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::verbosity::QUIET)
|
Arg::new(options::verbosity::QUIET)
|
||||||
.long(options::verbosity::QUIET)
|
.long(options::verbosity::QUIET)
|
||||||
.help("suppress most error messages"),
|
.help("suppress most error messages")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::RECURSIVE)
|
Arg::new(options::RECURSIVE)
|
||||||
.short('R')
|
.short('R')
|
||||||
.long(options::RECURSIVE)
|
.long(options::RECURSIVE)
|
||||||
.help("operate on files and directories recursively"),
|
.help("operate on files and directories recursively")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::REFERENCE)
|
Arg::new(options::REFERENCE)
|
||||||
|
@ -135,36 +144,41 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
.help("use RFILE's owner and group rather than specifying OWNER:GROUP values")
|
.help("use RFILE's owner and group rather than specifying OWNER:GROUP values")
|
||||||
.value_name("RFILE")
|
.value_name("RFILE")
|
||||||
.value_hint(clap::ValueHint::FilePath)
|
.value_hint(clap::ValueHint::FilePath)
|
||||||
.min_values(1),
|
.num_args(1..),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::verbosity::SILENT)
|
Arg::new(options::verbosity::SILENT)
|
||||||
.short('f')
|
.short('f')
|
||||||
.long(options::verbosity::SILENT),
|
.long(options::verbosity::SILENT)
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::traverse::TRAVERSE)
|
Arg::new(options::traverse::TRAVERSE)
|
||||||
.short(options::traverse::TRAVERSE.chars().next().unwrap())
|
.short(options::traverse::TRAVERSE.chars().next().unwrap())
|
||||||
.help("if a command line argument is a symbolic link to a directory, traverse it")
|
.help("if a command line argument is a symbolic link to a directory, traverse it")
|
||||||
.overrides_with_all(&[options::traverse::EVERY, options::traverse::NO_TRAVERSE]),
|
.overrides_with_all(&[options::traverse::EVERY, options::traverse::NO_TRAVERSE])
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::traverse::EVERY)
|
Arg::new(options::traverse::EVERY)
|
||||||
.short(options::traverse::EVERY.chars().next().unwrap())
|
.short(options::traverse::EVERY.chars().next().unwrap())
|
||||||
.help("traverse every symbolic link to a directory encountered")
|
.help("traverse every symbolic link to a directory encountered")
|
||||||
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::NO_TRAVERSE]),
|
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::NO_TRAVERSE])
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::traverse::NO_TRAVERSE)
|
Arg::new(options::traverse::NO_TRAVERSE)
|
||||||
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
|
.short(options::traverse::NO_TRAVERSE.chars().next().unwrap())
|
||||||
.help("do not traverse any symbolic links (default)")
|
.help("do not traverse any symbolic links (default)")
|
||||||
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::EVERY]),
|
.overrides_with_all(&[options::traverse::TRAVERSE, options::traverse::EVERY])
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::verbosity::VERBOSE)
|
Arg::new(options::verbosity::VERBOSE)
|
||||||
.long(options::verbosity::VERBOSE)
|
.long(options::verbosity::VERBOSE)
|
||||||
.short('v')
|
.short('v')
|
||||||
.help("output a diagnostic for every file processed"),
|
.help("output a diagnostic for every file processed")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue