1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

tac: update to clap 4

This commit is contained in:
Terts Diepraam 2022-10-01 00:18:50 +02:00
parent c7a7c4f2f2
commit 0611bd6fda
2 changed files with 9 additions and 9 deletions

View file

@ -20,7 +20,7 @@ path = "src/tac.rs"
memchr = "2" memchr = "2"
memmap2 = "0.5" memmap2 = "0.5"
regex = "1" 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" } uucore = { version=">=0.0.16", package="uucore", path="../../uucore" }
[[bin]] [[bin]]

View file

@ -8,7 +8,7 @@
// spell-checker:ignore (ToDO) sbytes slen dlen memmem memmap Mmap mmap SIGBUS // spell-checker:ignore (ToDO) sbytes slen dlen memmem memmap Mmap mmap SIGBUS
mod error; mod error;
use clap::{crate_version, Arg, Command}; use clap::{crate_version, Arg, ArgAction, Command};
use memchr::memmem; use memchr::memmem;
use memmap2::Mmap; use memmap2::Mmap;
use std::io::{stdin, stdout, BufWriter, Read, Write}; 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 matches = uu_app().try_get_matches_from(args)?;
let before = matches.contains_id(options::BEFORE); let before = matches.get_flag(options::BEFORE);
let regex = matches.contains_id(options::REGEX); let regex = matches.get_flag(options::REGEX);
let raw_separator = matches let raw_separator = matches
.get_one::<String>(options::SEPARATOR) .get_one::<String>(options::SEPARATOR)
.map(|s| s.as_str()) .map(|s| s.as_str())
@ -60,7 +60,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
tac(&files, before, regex, separator) tac(&files, before, regex, separator)
} }
pub fn uu_app<'a>() -> Command<'a> { pub fn uu_app() -> Command {
Command::new(uucore::util_name()) Command::new(uucore::util_name())
.name(NAME) .name(NAME)
.version(crate_version!()) .version(crate_version!())
@ -72,26 +72,26 @@ pub fn uu_app<'a>() -> Command<'a> {
.short('b') .short('b')
.long(options::BEFORE) .long(options::BEFORE)
.help("attach the separator before instead of after") .help("attach the separator before instead of after")
.takes_value(false), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::REGEX) Arg::new(options::REGEX)
.short('r') .short('r')
.long(options::REGEX) .long(options::REGEX)
.help("interpret the sequence as a regular expression") .help("interpret the sequence as a regular expression")
.takes_value(false), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::SEPARATOR) Arg::new(options::SEPARATOR)
.short('s') .short('s')
.long(options::SEPARATOR) .long(options::SEPARATOR)
.help("use STRING as the separator instead of newline") .help("use STRING as the separator instead of newline")
.takes_value(true), .value_name("STRING"),
) )
.arg( .arg(
Arg::new(options::FILE) Arg::new(options::FILE)
.hide(true) .hide(true)
.multiple_occurrences(true) .action(ArgAction::Append)
.value_hint(clap::ValueHint::FilePath), .value_hint(clap::ValueHint::FilePath),
) )
} }