mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
refactor: simplify the code by using the clap function instead
This commit is contained in:
parent
e45c56b926
commit
29694212dd
3 changed files with 12 additions and 27 deletions
|
@ -63,7 +63,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> Command {
|
pub fn uu_app() -> Command {
|
||||||
let mut cmd = 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))
|
||||||
|
@ -126,12 +126,7 @@ pub fn uu_app() -> Command {
|
||||||
.long(options::RECURSIVE)
|
.long(options::RECURSIVE)
|
||||||
.help("operate on files and directories recursively")
|
.help("operate on files and directories recursively")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
);
|
)
|
||||||
|
// Add common arguments with chgrp, chown & chmod
|
||||||
// Add common arguments with chgrp, chown & chmod
|
.args(uucore::perms::common_args())
|
||||||
for arg in uucore::perms::common_args() {
|
|
||||||
cmd = cmd.arg(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> Command {
|
pub fn uu_app() -> Command {
|
||||||
let mut cmd = 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))
|
||||||
|
@ -224,14 +224,9 @@ pub fn uu_app() -> Command {
|
||||||
.required_unless_present(options::MODE)
|
.required_unless_present(options::MODE)
|
||||||
.action(ArgAction::Append)
|
.action(ArgAction::Append)
|
||||||
.value_hint(clap::ValueHint::AnyPath),
|
.value_hint(clap::ValueHint::AnyPath),
|
||||||
);
|
)
|
||||||
|
// Add common arguments with chgrp, chown & chmod
|
||||||
// Add common arguments with chgrp, chown & chmod
|
.args(uucore::perms::common_args())
|
||||||
for arg in uucore::perms::common_args() {
|
|
||||||
cmd = cmd.arg(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Chmoder {
|
struct Chmoder {
|
||||||
|
|
|
@ -77,7 +77,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app() -> Command {
|
pub fn uu_app() -> Command {
|
||||||
let mut cmd = 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))
|
||||||
|
@ -152,14 +152,9 @@ pub fn uu_app() -> Command {
|
||||||
.short('v')
|
.short('v')
|
||||||
.help("output a diagnostic for every file processed")
|
.help("output a diagnostic for every file processed")
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
);
|
)
|
||||||
|
// Add common arguments with chgrp, chown & chmod
|
||||||
// Add common arguments with chgrp, chown & chmod
|
.args(uucore::perms::common_args())
|
||||||
for arg in uucore::perms::common_args() {
|
|
||||||
cmd = cmd.arg(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses the user string to extract the UID.
|
/// Parses the user string to extract the UID.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue