truncate: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 15:10:20 +01:00
parent 6c37cdebce
commit 263357666f
2 changed files with 15 additions and 15 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/truncate.rs" path = "src/truncate.rs"
[dependencies] [dependencies]
clap = { version = "2.33", features = ["wrap_help"] } clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" } uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
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

@ -97,7 +97,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let long_usage = get_long_usage(); let long_usage = get_long_usage();
let matches = uu_app() let matches = uu_app()
.usage(&usage[..]) .override_usage(&usage[..])
.after_help(&long_usage[..]) .after_help(&long_usage[..])
.get_matches_from(args); .get_matches_from(args);
@ -134,41 +134,41 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
} }
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::IO_BLOCKS) Arg::new(options::IO_BLOCKS)
.short("o") .short('o')
.long(options::IO_BLOCKS) .long(options::IO_BLOCKS)
.help("treat SIZE as the number of I/O blocks of the file rather than bytes (NOT IMPLEMENTED)") .help("treat SIZE as the number of I/O blocks of the file rather than bytes (NOT IMPLEMENTED)")
) )
.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 files that do not exist") .help("do not create files that do not exist")
) )
.arg( .arg(
Arg::with_name(options::REFERENCE) Arg::new(options::REFERENCE)
.short("r") .short('r')
.long(options::REFERENCE) .long(options::REFERENCE)
.required_unless(options::SIZE) .required_unless_present(options::SIZE)
.help("base the size of each file on the size of RFILE") .help("base the size of each file on the size of RFILE")
.value_name("RFILE") .value_name("RFILE")
) )
.arg( .arg(
Arg::with_name(options::SIZE) Arg::new(options::SIZE)
.short("s") .short('s')
.long(options::SIZE) .long(options::SIZE)
.required_unless(options::REFERENCE) .required_unless_present(options::REFERENCE)
.help("set or adjust the size of each file according to SIZE, which is in bytes unless --io-blocks is specified") .help("set or adjust the size of each file according to SIZE, which is in bytes unless --io-blocks is specified")
.value_name("SIZE") .value_name("SIZE")
) )
.arg(Arg::with_name(options::ARG_FILES) .arg(Arg::new(options::ARG_FILES)
.value_name("FILE") .value_name("FILE")
.multiple(true) .multiple_occurrences(true)
.takes_value(true) .takes_value(true)
.required(true) .required(true)
.min_values(1)) .min_values(1))