1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

wc: clap 3

This commit is contained in:
Terts Diepraam 2022-01-11 15:21:56 +01:00
parent e5a775be46
commit e9e5768591
2 changed files with 19 additions and 14 deletions

View file

@ -15,7 +15,7 @@ edition = "2018"
path = "src/wc.rs" path = "src/wc.rs"
[dependencies] [dependencies]
clap = { version = "2.33", features = ["wrap_help"] } clap = { version = "3.0", features = ["wrap_help", "cargo"] }
uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["pipes"] } uucore = { version=">=0.0.10", package="uucore", path="../../uucore", features=["pipes"] }
uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" } uucore_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
bytecount = "0.6.2" bytecount = "0.6.2"

View file

@ -137,7 +137,7 @@ impl Input {
pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let usage = usage(); let usage = usage();
let matches = uu_app().usage(&usage[..]).get_matches_from(args); let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let mut inputs: Vec<Input> = matches let mut inputs: Vec<Input> = matches
.values_of_os(ARG_FILES) .values_of_os(ARG_FILES)
@ -162,41 +162,46 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
wc(inputs, &settings) wc(inputs, &settings)
} }
pub fn uu_app() -> App<'static, 'static> { pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name()) App::new(uucore::util_name())
.version(crate_version!()) .version(crate_version!())
.about(ABOUT) .about(ABOUT)
.arg( .arg(
Arg::with_name(options::BYTES) Arg::new(options::BYTES)
.short("c") .short('c')
.long(options::BYTES) .long(options::BYTES)
.help("print the byte counts"), .help("print the byte counts"),
) )
.arg( .arg(
Arg::with_name(options::CHAR) Arg::new(options::CHAR)
.short("m") .short('m')
.long(options::CHAR) .long(options::CHAR)
.help("print the character counts"), .help("print the character counts"),
) )
.arg( .arg(
Arg::with_name(options::LINES) Arg::new(options::LINES)
.short("l") .short('l')
.long(options::LINES) .long(options::LINES)
.help("print the newline counts"), .help("print the newline counts"),
) )
.arg( .arg(
Arg::with_name(options::MAX_LINE_LENGTH) Arg::new(options::MAX_LINE_LENGTH)
.short("L") .short('L')
.long(options::MAX_LINE_LENGTH) .long(options::MAX_LINE_LENGTH)
.help("print the length of the longest line"), .help("print the length of the longest line"),
) )
.arg( .arg(
Arg::with_name(options::WORDS) Arg::new(options::WORDS)
.short("w") .short('w')
.long(options::WORDS) .long(options::WORDS)
.help("print the word counts"), .help("print the word counts"),
) )
.arg(Arg::with_name(ARG_FILES).multiple(true).takes_value(true)) .arg(
Arg::new(ARG_FILES)
.multiple_occurrences(true)
.takes_value(true)
.allow_invalid_utf8(true),
)
} }
fn word_count_from_reader<T: WordCountable>( fn word_count_from_reader<T: WordCountable>(