diff --git a/src/uu/tee/Cargo.toml b/src/uu/tee/Cargo.toml index dbba00403..311e09875 100644 --- a/src/uu/tee/Cargo.toml +++ b/src/uu/tee/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" path = "src/tee.rs" [dependencies] -clap = { version = "3.2", features = ["wrap_help", "cargo"] } +clap = { version = "4.0", features = ["wrap_help", "cargo"] } libc = "0.2.135" retain_mut = "=0.1.7" # ToDO: [2021-01-01; rivy; maint/MinSRV] ~ v0.1.5 uses const generics which aren't stabilized until rust v1.51.0 uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["libc"] } diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index 7159bf7fd..f5c3ab7f3 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -8,7 +8,7 @@ #[macro_use] extern crate uucore; -use clap::{crate_version, Arg, Command, PossibleValue}; +use clap::{builder::PossibleValue, crate_version, Arg, ArgAction, Command}; use retain_mut::RetainMut; use std::fs::OpenOptions; use std::io::{copy, sink, stdin, stdout, Error, ErrorKind, Read, Result, Write}; @@ -54,14 +54,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().try_get_matches_from(args)?; let options = Options { - append: matches.contains_id(options::APPEND), - ignore_interrupts: matches.contains_id(options::IGNORE_INTERRUPTS), + append: matches.get_flag(options::APPEND), + ignore_interrupts: matches.get_flag(options::IGNORE_INTERRUPTS), files: matches .get_many::(options::FILE) .map(|v| v.map(ToString::to_string).collect()) .unwrap_or_default(), output_error: { - if matches.contains_id(options::IGNORE_PIPE_ERRORS) { + if matches.get_flag(options::IGNORE_PIPE_ERRORS) { Some(OutputErrorMode::WarnNoPipe) } else if matches.contains_id(options::OUTPUT_ERROR) { if let Some(v) = matches.get_one::(options::OUTPUT_ERROR) { @@ -87,7 +87,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } } -pub fn uu_app<'a>() -> Command<'a> { +pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) @@ -98,30 +98,32 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(options::APPEND) .long(options::APPEND) .short('a') - .help("append to the given FILEs, do not overwrite"), + .help("append to the given FILEs, do not overwrite") + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::IGNORE_INTERRUPTS) .long(options::IGNORE_INTERRUPTS) .short('i') - .help("ignore interrupt signals (ignored on non-Unix platforms)"), + .help("ignore interrupt signals (ignored on non-Unix platforms)") + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::FILE) - .multiple_occurrences(true) + .action(ArgAction::Append) .value_hint(clap::ValueHint::FilePath), ) .arg( Arg::new(options::IGNORE_PIPE_ERRORS) .short('p') - .help("set write error behavior (ignored on non-Unix platforms)"), + .help("set write error behavior (ignored on non-Unix platforms)") + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::OUTPUT_ERROR) .long(options::OUTPUT_ERROR) .require_equals(true) - .min_values(0) - .max_values(1) + .num_args(0..=1) .value_parser([ PossibleValue::new("warn") .help("produce warnings for errors writing to any output"),