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"
[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_procs = { version=">=0.0.7", package="uucore_procs", path="../../uucore_procs" }
bytecount = "0.6.2"

View file

@ -137,7 +137,7 @@ impl Input {
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
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
.values_of_os(ARG_FILES)
@ -162,41 +162,46 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
wc(inputs, &settings)
}
pub fn uu_app() -> App<'static, 'static> {
pub fn uu_app<'a>() -> App<'a> {
App::new(uucore::util_name())
.version(crate_version!())
.about(ABOUT)
.arg(
Arg::with_name(options::BYTES)
.short("c")
Arg::new(options::BYTES)
.short('c')
.long(options::BYTES)
.help("print the byte counts"),
)
.arg(
Arg::with_name(options::CHAR)
.short("m")
Arg::new(options::CHAR)
.short('m')
.long(options::CHAR)
.help("print the character counts"),
)
.arg(
Arg::with_name(options::LINES)
.short("l")
Arg::new(options::LINES)
.short('l')
.long(options::LINES)
.help("print the newline counts"),
)
.arg(
Arg::with_name(options::MAX_LINE_LENGTH)
.short("L")
Arg::new(options::MAX_LINE_LENGTH)
.short('L')
.long(options::MAX_LINE_LENGTH)
.help("print the length of the longest line"),
)
.arg(
Arg::with_name(options::WORDS)
.short("w")
Arg::new(options::WORDS)
.short('w')
.long(options::WORDS)
.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>(