From 9f58715d65b917b5ed82c23578383ea6ec8f0494 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Tue, 11 Jan 2022 15:09:09 +0100 Subject: [PATCH] touch: clap 3 --- src/uu/touch/Cargo.toml | 2 +- src/uu/touch/src/touch.rs | 46 ++++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/uu/touch/Cargo.toml b/src/uu/touch/Cargo.toml index b21e2dfa3..947d3cbfb 100644 --- a/src/uu/touch/Cargo.toml +++ b/src/uu/touch/Cargo.toml @@ -16,7 +16,7 @@ path = "src/touch.rs" [dependencies] filetime = "0.2.1" -clap = { version = "2.33", features = ["wrap_help"] } +clap = { version = "3.0", features = ["wrap_help", "cargo"] } time = "0.1.40" uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["libc"] } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } diff --git a/src/uu/touch/src/touch.rs b/src/uu/touch/src/touch.rs index 6997def09..0ec3a6b1b 100644 --- a/src/uu/touch/src/touch.rs +++ b/src/uu/touch/src/touch.rs @@ -56,7 +56,7 @@ fn usage() -> String { pub fn uumain(args: impl uucore::Args) -> UResult<()> { 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 files = matches.values_of_os(ARG_FILES).unwrap(); @@ -129,43 +129,43 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Ok(()) } -pub fn uu_app() -> App<'static, 'static> { +pub fn uu_app<'a>() -> App<'a> { App::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) .arg( - Arg::with_name(options::ACCESS) - .short("a") + Arg::new(options::ACCESS) + .short('a') .help("change only the access time"), ) .arg( - Arg::with_name(options::sources::CURRENT) - .short("t") + Arg::new(options::sources::CURRENT) + .short('t') .help("use [[CC]YY]MMDDhhmm[.ss] instead of the current time") .value_name("STAMP") .takes_value(true), ) .arg( - Arg::with_name(options::sources::DATE) - .short("d") + Arg::new(options::sources::DATE) + .short('d') .long(options::sources::DATE) .help("parse argument and use it instead of current time") .value_name("STRING"), ) .arg( - Arg::with_name(options::MODIFICATION) - .short("m") + Arg::new(options::MODIFICATION) + .short('m') .help("change only the modification time"), ) .arg( - Arg::with_name(options::NO_CREATE) - .short("c") + Arg::new(options::NO_CREATE) + .short('c') .long(options::NO_CREATE) .help("do not create any files"), ) .arg( - Arg::with_name(options::NO_DEREF) - .short("h") + Arg::new(options::NO_DEREF) + .short('h') .long(options::NO_DEREF) .help( "affect each symbolic link instead of any referenced file \ @@ -173,15 +173,16 @@ pub fn uu_app() -> App<'static, 'static> { ), ) .arg( - Arg::with_name(options::sources::REFERENCE) - .short("r") + Arg::new(options::sources::REFERENCE) + .short('r') .long(options::sources::REFERENCE) .alias("ref") // clapv3 .help("use this file's times instead of the current time") - .value_name("FILE"), + .value_name("FILE") + .allow_invalid_utf8(true), ) .arg( - Arg::with_name(options::TIME) + Arg::new(options::TIME) .long(options::TIME) .help( "change only the specified time: \"access\", \"atime\", or \ @@ -193,12 +194,13 @@ pub fn uu_app() -> App<'static, 'static> { .takes_value(true), ) .arg( - Arg::with_name(ARG_FILES) - .multiple(true) + Arg::new(ARG_FILES) + .multiple_occurrences(true) .takes_value(true) - .min_values(1), + .min_values(1) + .allow_invalid_utf8(true), ) - .group(ArgGroup::with_name(options::SOURCES).args(&[ + .group(ArgGroup::new(options::SOURCES).args(&[ options::sources::CURRENT, options::sources::DATE, options::sources::REFERENCE,