mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 15:22:38 +00:00
uniq: clap 3
This commit is contained in:
parent
dafa0737c8
commit
5105a59fda
2 changed files with 31 additions and 27 deletions
|
@ -15,7 +15,7 @@ edition = "2018"
|
|||
path = "src/uniq.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "2.33", features = ["wrap_help"] }
|
||||
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
|
||||
strum = "0.21"
|
||||
strum_macros = "0.21"
|
||||
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
|
||||
|
|
|
@ -261,7 +261,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
let long_usage = get_long_usage();
|
||||
|
||||
let matches = uu_app()
|
||||
.usage(&usage[..])
|
||||
.override_usage(&usage[..])
|
||||
.after_help(&long_usage[..])
|
||||
.get_matches_from(args);
|
||||
|
||||
|
@ -299,16 +299,18 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
)
|
||||
}
|
||||
|
||||
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::ALL_REPEATED)
|
||||
.short("D")
|
||||
Arg::new(options::ALL_REPEATED)
|
||||
.short('D')
|
||||
.long(options::ALL_REPEATED)
|
||||
.possible_values(&[
|
||||
Delimiters::None.as_ref(), Delimiters::Prepend.as_ref(), Delimiters::Separate.as_ref()
|
||||
"none",
|
||||
"prepend",
|
||||
"separate"
|
||||
])
|
||||
.help("print all duplicate lines. Delimiting is done with blank lines. [default: none]")
|
||||
.value_name("delimit-method")
|
||||
|
@ -316,11 +318,13 @@ pub fn uu_app() -> App<'static, 'static> {
|
|||
.max_values(1),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::GROUP)
|
||||
Arg::new(options::GROUP)
|
||||
.long(options::GROUP)
|
||||
.possible_values(&[
|
||||
Delimiters::Separate.as_ref(), Delimiters::Prepend.as_ref(),
|
||||
Delimiters::Append.as_ref(), Delimiters::Both.as_ref()
|
||||
"separate",
|
||||
"prepend",
|
||||
"append",
|
||||
"both",
|
||||
])
|
||||
.help("show all items, separating groups with an empty line. [default: separate]")
|
||||
.value_name("group-method")
|
||||
|
@ -333,59 +337,59 @@ pub fn uu_app() -> App<'static, 'static> {
|
|||
]),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::CHECK_CHARS)
|
||||
.short("w")
|
||||
Arg::new(options::CHECK_CHARS)
|
||||
.short('w')
|
||||
.long(options::CHECK_CHARS)
|
||||
.help("compare no more than N characters in lines")
|
||||
.value_name("N"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::COUNT)
|
||||
.short("c")
|
||||
Arg::new(options::COUNT)
|
||||
.short('c')
|
||||
.long(options::COUNT)
|
||||
.help("prefix lines by the number of occurrences"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::IGNORE_CASE)
|
||||
.short("i")
|
||||
Arg::new(options::IGNORE_CASE)
|
||||
.short('i')
|
||||
.long(options::IGNORE_CASE)
|
||||
.help("ignore differences in case when comparing"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::REPEATED)
|
||||
.short("d")
|
||||
Arg::new(options::REPEATED)
|
||||
.short('d')
|
||||
.long(options::REPEATED)
|
||||
.help("only print duplicate lines"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::SKIP_CHARS)
|
||||
.short("s")
|
||||
Arg::new(options::SKIP_CHARS)
|
||||
.short('s')
|
||||
.long(options::SKIP_CHARS)
|
||||
.help("avoid comparing the first N characters")
|
||||
.value_name("N"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::SKIP_FIELDS)
|
||||
.short("f")
|
||||
Arg::new(options::SKIP_FIELDS)
|
||||
.short('f')
|
||||
.long(options::SKIP_FIELDS)
|
||||
.help("avoid comparing the first N fields")
|
||||
.value_name("N"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::UNIQUE)
|
||||
.short("u")
|
||||
Arg::new(options::UNIQUE)
|
||||
.short('u')
|
||||
.long(options::UNIQUE)
|
||||
.help("only print unique lines"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(options::ZERO_TERMINATED)
|
||||
.short("z")
|
||||
Arg::new(options::ZERO_TERMINATED)
|
||||
.short('z')
|
||||
.long(options::ZERO_TERMINATED)
|
||||
.help("end lines with 0 byte, not newline"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name(ARG_FILES)
|
||||
.multiple(true)
|
||||
Arg::new(ARG_FILES)
|
||||
.multiple_occurrences(true)
|
||||
.takes_value(true)
|
||||
.max_values(2),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue