1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 13:07:46 +00:00

readlink: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 14:39:21 +01:00
parent 24dc4d9037
commit d8f2be2f3b
2 changed files with 24 additions and 20 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/readlink.rs" path = "src/readlink.rs"
[dependencies] [dependencies]
clap = { version = "2.33", features = ["wrap_help"] } clap = { version = "3.0", features = ["wrap_help", "cargo"] }
libc = "0.2.42" libc = "0.2.42"
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] } uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }

View file

@ -37,7 +37,7 @@ fn usage() -> String {
#[uucore_procs::gen_uumain] #[uucore_procs::gen_uumain]
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 mut no_newline = matches.is_present(OPT_NO_NEWLINE); let mut no_newline = matches.is_present(OPT_NO_NEWLINE);
let use_zero = matches.is_present(OPT_ZERO); let use_zero = matches.is_present(OPT_ZERO);
@ -98,13 +98,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
Ok(()) Ok(())
} }
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_CANONICALIZE) Arg::new(OPT_CANONICALIZE)
.short("f") .short('f')
.long(OPT_CANONICALIZE) .long(OPT_CANONICALIZE)
.help( .help(
"canonicalize by following every symlink in every component of the \ "canonicalize by following every symlink in every component of the \
@ -112,8 +112,8 @@ pub fn uu_app() -> App<'static, 'static> {
), ),
) )
.arg( .arg(
Arg::with_name(OPT_CANONICALIZE_EXISTING) Arg::new(OPT_CANONICALIZE_EXISTING)
.short("e") .short('e')
.long("canonicalize-existing") .long("canonicalize-existing")
.help( .help(
"canonicalize by following every symlink in every component of the \ "canonicalize by following every symlink in every component of the \
@ -121,8 +121,8 @@ pub fn uu_app() -> App<'static, 'static> {
), ),
) )
.arg( .arg(
Arg::with_name(OPT_CANONICALIZE_MISSING) Arg::new(OPT_CANONICALIZE_MISSING)
.short("m") .short('m')
.long(OPT_CANONICALIZE_MISSING) .long(OPT_CANONICALIZE_MISSING)
.help( .help(
"canonicalize by following every symlink in every component of the \ "canonicalize by following every symlink in every component of the \
@ -130,36 +130,40 @@ pub fn uu_app() -> App<'static, 'static> {
), ),
) )
.arg( .arg(
Arg::with_name(OPT_NO_NEWLINE) Arg::new(OPT_NO_NEWLINE)
.short("n") .short('n')
.long(OPT_NO_NEWLINE) .long(OPT_NO_NEWLINE)
.help("do not output the trailing delimiter"), .help("do not output the trailing delimiter"),
) )
.arg( .arg(
Arg::with_name(OPT_QUIET) Arg::new(OPT_QUIET)
.short("q") .short('q')
.long(OPT_QUIET) .long(OPT_QUIET)
.help("suppress most error messages"), .help("suppress most error messages"),
) )
.arg( .arg(
Arg::with_name(OPT_SILENT) Arg::new(OPT_SILENT)
.short("s") .short('s')
.long(OPT_SILENT) .long(OPT_SILENT)
.help("suppress most error messages"), .help("suppress most error messages"),
) )
.arg( .arg(
Arg::with_name(OPT_VERBOSE) Arg::new(OPT_VERBOSE)
.short("v") .short('v')
.long(OPT_VERBOSE) .long(OPT_VERBOSE)
.help("report error message"), .help("report error message"),
) )
.arg( .arg(
Arg::with_name(OPT_ZERO) Arg::new(OPT_ZERO)
.short("z") .short('z')
.long(OPT_ZERO) .long(OPT_ZERO)
.help("separate output with NUL rather than newline"), .help("separate output with NUL rather than newline"),
) )
.arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true)) .arg(
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true),
)
} }
fn show(path: &Path, no_newline: bool, use_zero: bool) -> std::io::Result<()> { fn show(path: &Path, no_newline: bool, use_zero: bool) -> std::io::Result<()> {