1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tee: update to clap 4

This commit is contained in:
Terts Diepraam 2022-10-01 11:02:51 +02:00
parent c8536c0985
commit b15c6eb293
2 changed files with 14 additions and 12 deletions

View file

@ -15,7 +15,7 @@ edition = "2021"
path = "src/tee.rs" path = "src/tee.rs"
[dependencies] [dependencies]
clap = { version = "3.2", features = ["wrap_help", "cargo"] } clap = { version = "4.0", features = ["wrap_help", "cargo"] }
libc = "0.2.135" 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 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"] } uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["libc"] }

View file

@ -8,7 +8,7 @@
#[macro_use] #[macro_use]
extern crate uucore; extern crate uucore;
use clap::{crate_version, Arg, Command, PossibleValue}; use clap::{builder::PossibleValue, crate_version, Arg, ArgAction, Command};
use retain_mut::RetainMut; use retain_mut::RetainMut;
use std::fs::OpenOptions; use std::fs::OpenOptions;
use std::io::{copy, sink, stdin, stdout, Error, ErrorKind, Read, Result, Write}; 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 matches = uu_app().try_get_matches_from(args)?;
let options = Options { let options = Options {
append: matches.contains_id(options::APPEND), append: matches.get_flag(options::APPEND),
ignore_interrupts: matches.contains_id(options::IGNORE_INTERRUPTS), ignore_interrupts: matches.get_flag(options::IGNORE_INTERRUPTS),
files: matches files: matches
.get_many::<String>(options::FILE) .get_many::<String>(options::FILE)
.map(|v| v.map(ToString::to_string).collect()) .map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default(), .unwrap_or_default(),
output_error: { output_error: {
if matches.contains_id(options::IGNORE_PIPE_ERRORS) { if matches.get_flag(options::IGNORE_PIPE_ERRORS) {
Some(OutputErrorMode::WarnNoPipe) Some(OutputErrorMode::WarnNoPipe)
} else if matches.contains_id(options::OUTPUT_ERROR) { } else if matches.contains_id(options::OUTPUT_ERROR) {
if let Some(v) = matches.get_one::<String>(options::OUTPUT_ERROR) { if let Some(v) = matches.get_one::<String>(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()) Command::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
@ -98,30 +98,32 @@ pub fn uu_app<'a>() -> Command<'a> {
Arg::new(options::APPEND) Arg::new(options::APPEND)
.long(options::APPEND) .long(options::APPEND)
.short('a') .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(
Arg::new(options::IGNORE_INTERRUPTS) Arg::new(options::IGNORE_INTERRUPTS)
.long(options::IGNORE_INTERRUPTS) .long(options::IGNORE_INTERRUPTS)
.short('i') .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(
Arg::new(options::FILE) Arg::new(options::FILE)
.multiple_occurrences(true) .action(ArgAction::Append)
.value_hint(clap::ValueHint::FilePath), .value_hint(clap::ValueHint::FilePath),
) )
.arg( .arg(
Arg::new(options::IGNORE_PIPE_ERRORS) Arg::new(options::IGNORE_PIPE_ERRORS)
.short('p') .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(
Arg::new(options::OUTPUT_ERROR) Arg::new(options::OUTPUT_ERROR)
.long(options::OUTPUT_ERROR) .long(options::OUTPUT_ERROR)
.require_equals(true) .require_equals(true)
.min_values(0) .num_args(0..=1)
.max_values(1)
.value_parser([ .value_parser([
PossibleValue::new("warn") PossibleValue::new("warn")
.help("produce warnings for errors writing to any output"), .help("produce warnings for errors writing to any output"),