mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 23:32:39 +00:00
touch: clap 3
This commit is contained in:
parent
7318d1d24b
commit
9f58715d65
2 changed files with 25 additions and 23 deletions
|
@ -16,7 +16,7 @@ path = "src/touch.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
filetime = "0.2.1"
|
filetime = "0.2.1"
|
||||||
clap = { version = "2.33", features = ["wrap_help"] }
|
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
|
||||||
time = "0.1.40"
|
time = "0.1.40"
|
||||||
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["libc"] }
|
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["libc"] }
|
||||||
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
|
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
|
||||||
|
|
|
@ -56,7 +56,7 @@ fn usage() -> String {
|
||||||
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 files = matches.values_of_os(ARG_FILES).unwrap();
|
let files = matches.values_of_os(ARG_FILES).unwrap();
|
||||||
|
|
||||||
|
@ -129,43 +129,43 @@ 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(options::ACCESS)
|
Arg::new(options::ACCESS)
|
||||||
.short("a")
|
.short('a')
|
||||||
.help("change only the access time"),
|
.help("change only the access time"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::sources::CURRENT)
|
Arg::new(options::sources::CURRENT)
|
||||||
.short("t")
|
.short('t')
|
||||||
.help("use [[CC]YY]MMDDhhmm[.ss] instead of the current time")
|
.help("use [[CC]YY]MMDDhhmm[.ss] instead of the current time")
|
||||||
.value_name("STAMP")
|
.value_name("STAMP")
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::sources::DATE)
|
Arg::new(options::sources::DATE)
|
||||||
.short("d")
|
.short('d')
|
||||||
.long(options::sources::DATE)
|
.long(options::sources::DATE)
|
||||||
.help("parse argument and use it instead of current time")
|
.help("parse argument and use it instead of current time")
|
||||||
.value_name("STRING"),
|
.value_name("STRING"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::MODIFICATION)
|
Arg::new(options::MODIFICATION)
|
||||||
.short("m")
|
.short('m')
|
||||||
.help("change only the modification time"),
|
.help("change only the modification time"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::NO_CREATE)
|
Arg::new(options::NO_CREATE)
|
||||||
.short("c")
|
.short('c')
|
||||||
.long(options::NO_CREATE)
|
.long(options::NO_CREATE)
|
||||||
.help("do not create any files"),
|
.help("do not create any files"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::NO_DEREF)
|
Arg::new(options::NO_DEREF)
|
||||||
.short("h")
|
.short('h')
|
||||||
.long(options::NO_DEREF)
|
.long(options::NO_DEREF)
|
||||||
.help(
|
.help(
|
||||||
"affect each symbolic link instead of any referenced file \
|
"affect each symbolic link instead of any referenced file \
|
||||||
|
@ -173,15 +173,16 @@ pub fn uu_app() -> App<'static, 'static> {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::sources::REFERENCE)
|
Arg::new(options::sources::REFERENCE)
|
||||||
.short("r")
|
.short('r')
|
||||||
.long(options::sources::REFERENCE)
|
.long(options::sources::REFERENCE)
|
||||||
.alias("ref") // clapv3
|
.alias("ref") // clapv3
|
||||||
.help("use this file's times instead of the current time")
|
.help("use this file's times instead of the current time")
|
||||||
.value_name("FILE"),
|
.value_name("FILE")
|
||||||
|
.allow_invalid_utf8(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::TIME)
|
Arg::new(options::TIME)
|
||||||
.long(options::TIME)
|
.long(options::TIME)
|
||||||
.help(
|
.help(
|
||||||
"change only the specified time: \"access\", \"atime\", or \
|
"change only the specified time: \"access\", \"atime\", or \
|
||||||
|
@ -193,12 +194,13 @@ pub fn uu_app() -> App<'static, 'static> {
|
||||||
.takes_value(true),
|
.takes_value(true),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(ARG_FILES)
|
Arg::new(ARG_FILES)
|
||||||
.multiple(true)
|
.multiple_occurrences(true)
|
||||||
.takes_value(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::CURRENT,
|
||||||
options::sources::DATE,
|
options::sources::DATE,
|
||||||
options::sources::REFERENCE,
|
options::sources::REFERENCE,
|
||||||
|
|
Loading…
Reference in a new issue