From 0611bd6fda8306862fff72ee983d96311c437c01 Mon Sep 17 00:00:00 2001 From: Terts Diepraam Date: Sat, 1 Oct 2022 00:18:50 +0200 Subject: [PATCH] tac: update to clap 4 --- src/uu/tac/Cargo.toml | 2 +- src/uu/tac/src/tac.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/uu/tac/Cargo.toml b/src/uu/tac/Cargo.toml index 01292d5e1..bd00ffe5e 100644 --- a/src/uu/tac/Cargo.toml +++ b/src/uu/tac/Cargo.toml @@ -20,7 +20,7 @@ path = "src/tac.rs" memchr = "2" memmap2 = "0.5" regex = "1" -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/tac/src/tac.rs b/src/uu/tac/src/tac.rs index d778a48c4..7a448ca3d 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -8,7 +8,7 @@ // spell-checker:ignore (ToDO) sbytes slen dlen memmem memmap Mmap mmap SIGBUS mod error; -use clap::{crate_version, Arg, Command}; +use clap::{crate_version, Arg, ArgAction, Command}; use memchr::memmem; use memmap2::Mmap; use std::io::{stdin, stdout, BufWriter, Read, Write}; @@ -40,8 +40,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().try_get_matches_from(args)?; - let before = matches.contains_id(options::BEFORE); - let regex = matches.contains_id(options::REGEX); + let before = matches.get_flag(options::BEFORE); + let regex = matches.get_flag(options::REGEX); let raw_separator = matches .get_one::(options::SEPARATOR) .map(|s| s.as_str()) @@ -60,7 +60,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { tac(&files, before, regex, separator) } -pub fn uu_app<'a>() -> Command<'a> { +pub fn uu_app() -> Command { Command::new(uucore::util_name()) .name(NAME) .version(crate_version!()) @@ -72,26 +72,26 @@ pub fn uu_app<'a>() -> Command<'a> { .short('b') .long(options::BEFORE) .help("attach the separator before instead of after") - .takes_value(false), + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::REGEX) .short('r') .long(options::REGEX) .help("interpret the sequence as a regular expression") - .takes_value(false), + .action(ArgAction::SetTrue), ) .arg( Arg::new(options::SEPARATOR) .short('s') .long(options::SEPARATOR) .help("use STRING as the separator instead of newline") - .takes_value(true), + .value_name("STRING"), ) .arg( Arg::new(options::FILE) .hide(true) - .multiple_occurrences(true) + .action(ArgAction::Append) .value_hint(clap::ValueHint::FilePath), ) }