From e346253a308671b4e082add69fbe7fc545f16121 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Thu, 29 Sep 2022 23:23:05 +0200 Subject: [PATCH] paste: update to clap 4 --- src/uu/paste/Cargo.toml | 2 +- src/uu/paste/src/paste.rs | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/uu/paste/Cargo.toml b/src/uu/paste/Cargo.toml index 80f113580..a3625d2c5 100644 --- a/src/uu/paste/Cargo.toml +++ b/src/uu/paste/Cargo.toml @@ -15,7 +15,7 @@ edition = "2021" path = "src/paste.rs" [dependencies] -clap = { version = "3.2", features = ["wrap_help", "cargo"] } +clap = { version = "4.0", features = ["wrap_help", "cargo"] } uucore = { version=">=0.0.16", package="uucore", path="../../uucore" } [[bin]] diff --git a/src/uu/paste/src/paste.rs b/src/uu/paste/src/paste.rs index af8e0f416..3635ae967 100644 --- a/src/uu/paste/src/paste.rs +++ b/src/uu/paste/src/paste.rs @@ -7,7 +7,7 @@ // spell-checker:ignore (ToDO) delim -use clap::{crate_version, Arg, Command}; +use clap::{crate_version, Arg, ArgAction, Command}; use std::fmt::Display; use std::fs::File; use std::io::{stdin, stdout, BufRead, BufReader, Read, Write}; @@ -56,14 +56,14 @@ fn read_until( pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().try_get_matches_from(args)?; - let serial = matches.contains_id(options::SERIAL); + let serial = matches.get_flag(options::SERIAL); let delimiters = matches.get_one::(options::DELIMITER).unwrap(); let files = matches .get_many::(options::FILE) .unwrap() .map(|s| s.to_owned()) .collect(); - let line_ending = if matches.contains_id(options::ZERO_TERMINATED) { + let line_ending = if matches.get_flag(options::ZERO_TERMINATED) { LineEnding::Nul } else { LineEnding::Newline @@ -72,7 +72,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { paste(files, serial, delimiters, line_ending) } -pub fn uu_app<'a>() -> Command<'a> { +pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(crate_version!()) .about(ABOUT) @@ -81,7 +81,8 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(options::SERIAL) .long(options::SERIAL) .short('s') - .help("paste one file at a time instead of in parallel"), + .help("paste one file at a time instead of in parallel") + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::DELIMITER) @@ -95,7 +96,7 @@ pub fn uu_app<'a>() -> Command<'a> { .arg( Arg::new(options::FILE) .value_name("FILE") - .multiple_occurrences(true) + .action(ArgAction::Append) .default_value("-") .value_hint(clap::ValueHint::FilePath), ) @@ -103,7 +104,8 @@ pub fn uu_app<'a>() -> Command<'a> { Arg::new(options::ZERO_TERMINATED) .long(options::ZERO_TERMINATED) .short('z') - .help("line delimiter is NUL, not newline"), + .help("line delimiter is NUL, not newline") + .action(ArgAction::SetTrue), ) }