mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
wc: update to clap 4
This commit is contained in:
parent
60d51910e6
commit
92c4b32eeb
2 changed files with 19 additions and 16 deletions
|
@ -15,7 +15,7 @@ edition = "2021"
|
||||||
path = "src/wc.rs"
|
path = "src/wc.rs"
|
||||||
|
|
||||||
[dependencies]
|
[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", features=["pipes"] }
|
uucore = { version=">=0.0.16", package="uucore", path="../../uucore", features=["pipes"] }
|
||||||
bytecount = "0.6.3"
|
bytecount = "0.6.3"
|
||||||
utf-8 = "0.7.6"
|
utf-8 = "0.7.6"
|
||||||
|
|
|
@ -21,7 +21,7 @@ use utf8::{BufReadDecoder, BufReadDecoderError};
|
||||||
use uucore::format_usage;
|
use uucore::format_usage;
|
||||||
use word_count::{TitledWordCount, WordCount};
|
use word_count::{TitledWordCount, WordCount};
|
||||||
|
|
||||||
use clap::{crate_version, Arg, ArgMatches, Command};
|
use clap::{crate_version, Arg, ArgAction, ArgMatches, Command};
|
||||||
|
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
@ -61,11 +61,11 @@ impl Settings {
|
||||||
};
|
};
|
||||||
|
|
||||||
let settings = Self {
|
let settings = Self {
|
||||||
show_bytes: matches.contains_id(options::BYTES),
|
show_bytes: matches.get_flag(options::BYTES),
|
||||||
show_chars: matches.contains_id(options::CHAR),
|
show_chars: matches.get_flag(options::CHAR),
|
||||||
show_lines: matches.contains_id(options::LINES),
|
show_lines: matches.get_flag(options::LINES),
|
||||||
show_words: matches.contains_id(options::WORDS),
|
show_words: matches.get_flag(options::WORDS),
|
||||||
show_max_line_length: matches.contains_id(options::MAX_LINE_LENGTH),
|
show_max_line_length: matches.get_flag(options::MAX_LINE_LENGTH),
|
||||||
files0_from_stdin_mode,
|
files0_from_stdin_mode,
|
||||||
title_quoting_style,
|
title_quoting_style,
|
||||||
};
|
};
|
||||||
|
@ -205,7 +205,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
wc(&inputs, &settings)
|
wc(&inputs, &settings)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uu_app<'a>() -> Command<'a> {
|
pub fn uu_app() -> Command {
|
||||||
Command::new(uucore::util_name())
|
Command::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
|
@ -215,18 +215,19 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(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")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(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")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FILES0_FROM)
|
Arg::new(options::FILES0_FROM)
|
||||||
.long(options::FILES0_FROM)
|
.long(options::FILES0_FROM)
|
||||||
.takes_value(true)
|
|
||||||
.value_name("F")
|
.value_name("F")
|
||||||
.help(
|
.help(
|
||||||
"read input from the files specified by
|
"read input from the files specified by
|
||||||
|
@ -239,24 +240,26 @@ pub fn uu_app<'a>() -> Command<'a> {
|
||||||
Arg::new(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")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(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")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(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")
|
||||||
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(ARG_FILES)
|
Arg::new(ARG_FILES)
|
||||||
.multiple_occurrences(true)
|
.action(ArgAction::Append)
|
||||||
.takes_value(true)
|
|
||||||
.value_parser(ValueParser::os_string())
|
.value_parser(ValueParser::os_string())
|
||||||
.value_hint(clap::ValueHint::FilePath),
|
.value_hint(clap::ValueHint::FilePath),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue