mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +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"
|
path = "src/uniq.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = { version = "2.33", features = ["wrap_help"] }
|
clap = { version = "3.0", features = ["wrap_help", "cargo"] }
|
||||||
strum = "0.21"
|
strum = "0.21"
|
||||||
strum_macros = "0.21"
|
strum_macros = "0.21"
|
||||||
uucore = { version=">=0.0.10", package="uucore", path="../../uucore" }
|
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 long_usage = get_long_usage();
|
||||||
|
|
||||||
let matches = uu_app()
|
let matches = uu_app()
|
||||||
.usage(&usage[..])
|
.override_usage(&usage[..])
|
||||||
.after_help(&long_usage[..])
|
.after_help(&long_usage[..])
|
||||||
.get_matches_from(args);
|
.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())
|
App::new(uucore::util_name())
|
||||||
.version(crate_version!())
|
.version(crate_version!())
|
||||||
.about(ABOUT)
|
.about(ABOUT)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::ALL_REPEATED)
|
Arg::new(options::ALL_REPEATED)
|
||||||
.short("D")
|
.short('D')
|
||||||
.long(options::ALL_REPEATED)
|
.long(options::ALL_REPEATED)
|
||||||
.possible_values(&[
|
.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]")
|
.help("print all duplicate lines. Delimiting is done with blank lines. [default: none]")
|
||||||
.value_name("delimit-method")
|
.value_name("delimit-method")
|
||||||
|
@ -316,11 +318,13 @@ pub fn uu_app() -> App<'static, 'static> {
|
||||||
.max_values(1),
|
.max_values(1),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::GROUP)
|
Arg::new(options::GROUP)
|
||||||
.long(options::GROUP)
|
.long(options::GROUP)
|
||||||
.possible_values(&[
|
.possible_values(&[
|
||||||
Delimiters::Separate.as_ref(), Delimiters::Prepend.as_ref(),
|
"separate",
|
||||||
Delimiters::Append.as_ref(), Delimiters::Both.as_ref()
|
"prepend",
|
||||||
|
"append",
|
||||||
|
"both",
|
||||||
])
|
])
|
||||||
.help("show all items, separating groups with an empty line. [default: separate]")
|
.help("show all items, separating groups with an empty line. [default: separate]")
|
||||||
.value_name("group-method")
|
.value_name("group-method")
|
||||||
|
@ -333,59 +337,59 @@ pub fn uu_app() -> App<'static, 'static> {
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::CHECK_CHARS)
|
Arg::new(options::CHECK_CHARS)
|
||||||
.short("w")
|
.short('w')
|
||||||
.long(options::CHECK_CHARS)
|
.long(options::CHECK_CHARS)
|
||||||
.help("compare no more than N characters in lines")
|
.help("compare no more than N characters in lines")
|
||||||
.value_name("N"),
|
.value_name("N"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::COUNT)
|
Arg::new(options::COUNT)
|
||||||
.short("c")
|
.short('c')
|
||||||
.long(options::COUNT)
|
.long(options::COUNT)
|
||||||
.help("prefix lines by the number of occurrences"),
|
.help("prefix lines by the number of occurrences"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::IGNORE_CASE)
|
Arg::new(options::IGNORE_CASE)
|
||||||
.short("i")
|
.short('i')
|
||||||
.long(options::IGNORE_CASE)
|
.long(options::IGNORE_CASE)
|
||||||
.help("ignore differences in case when comparing"),
|
.help("ignore differences in case when comparing"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::REPEATED)
|
Arg::new(options::REPEATED)
|
||||||
.short("d")
|
.short('d')
|
||||||
.long(options::REPEATED)
|
.long(options::REPEATED)
|
||||||
.help("only print duplicate lines"),
|
.help("only print duplicate lines"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::SKIP_CHARS)
|
Arg::new(options::SKIP_CHARS)
|
||||||
.short("s")
|
.short('s')
|
||||||
.long(options::SKIP_CHARS)
|
.long(options::SKIP_CHARS)
|
||||||
.help("avoid comparing the first N characters")
|
.help("avoid comparing the first N characters")
|
||||||
.value_name("N"),
|
.value_name("N"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::SKIP_FIELDS)
|
Arg::new(options::SKIP_FIELDS)
|
||||||
.short("f")
|
.short('f')
|
||||||
.long(options::SKIP_FIELDS)
|
.long(options::SKIP_FIELDS)
|
||||||
.help("avoid comparing the first N fields")
|
.help("avoid comparing the first N fields")
|
||||||
.value_name("N"),
|
.value_name("N"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::UNIQUE)
|
Arg::new(options::UNIQUE)
|
||||||
.short("u")
|
.short('u')
|
||||||
.long(options::UNIQUE)
|
.long(options::UNIQUE)
|
||||||
.help("only print unique lines"),
|
.help("only print unique lines"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(options::ZERO_TERMINATED)
|
Arg::new(options::ZERO_TERMINATED)
|
||||||
.short("z")
|
.short('z')
|
||||||
.long(options::ZERO_TERMINATED)
|
.long(options::ZERO_TERMINATED)
|
||||||
.help("end lines with 0 byte, not newline"),
|
.help("end lines with 0 byte, not newline"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(ARG_FILES)
|
Arg::new(ARG_FILES)
|
||||||
.multiple(true)
|
.multiple_occurrences(true)
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.max_values(2),
|
.max_values(2),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue