mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
uniq: accept shortcuts for stringly-enum arguments
This commit is contained in:
parent
3285f95eb3
commit
a699bfd1fb
2 changed files with 65 additions and 4 deletions
|
@ -14,6 +14,7 @@ use std::num::IntErrorKind;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{FromIo, UError, UResult, USimpleError};
|
use uucore::error::{FromIo, UError, UResult, USimpleError};
|
||||||
use uucore::posix::{posix_version, OBSOLETE};
|
use uucore::posix::{posix_version, OBSOLETE};
|
||||||
|
use uucore::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||||
|
|
||||||
const ABOUT: &str = help_about!("uniq.md");
|
const ABOUT: &str = help_about!("uniq.md");
|
||||||
|
@ -609,11 +610,11 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::ALL_REPEATED)
|
Arg::new(options::ALL_REPEATED)
|
||||||
.short('D')
|
.short('D')
|
||||||
.long(options::ALL_REPEATED)
|
.long(options::ALL_REPEATED)
|
||||||
.value_parser([
|
.value_parser(ShortcutValueParser::new([
|
||||||
"none",
|
"none",
|
||||||
"prepend",
|
"prepend",
|
||||||
"separate"
|
"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")
|
||||||
.num_args(0..=1)
|
.num_args(0..=1)
|
||||||
|
@ -623,12 +624,12 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::GROUP)
|
Arg::new(options::GROUP)
|
||||||
.long(options::GROUP)
|
.long(options::GROUP)
|
||||||
.value_parser([
|
.value_parser(ShortcutValueParser::new([
|
||||||
"separate",
|
"separate",
|
||||||
"prepend",
|
"prepend",
|
||||||
"append",
|
"append",
|
||||||
"both",
|
"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")
|
||||||
.num_args(0..=1)
|
.num_args(0..=1)
|
||||||
|
|
|
@ -145,6 +145,21 @@ fn test_stdin_all_repeated() {
|
||||||
.pipe_in_fixture(INPUT)
|
.pipe_in_fixture(INPUT)
|
||||||
.run()
|
.run()
|
||||||
.stdout_is_fixture("sorted-all-repeated.expected");
|
.stdout_is_fixture("sorted-all-repeated.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--all-repeated=none"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("sorted-all-repeated.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--all-repeated=non"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("sorted-all-repeated.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--all-repeated=n"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("sorted-all-repeated.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -167,6 +182,16 @@ fn test_stdin_all_repeated_separate() {
|
||||||
.pipe_in_fixture(INPUT)
|
.pipe_in_fixture(INPUT)
|
||||||
.run()
|
.run()
|
||||||
.stdout_is_fixture("sorted-all-repeated-separate.expected");
|
.stdout_is_fixture("sorted-all-repeated-separate.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--all-repeated=separat"]) // spell-checker:disable-line
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("sorted-all-repeated-separate.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--all-repeated=s"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("sorted-all-repeated-separate.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -176,6 +201,16 @@ fn test_stdin_all_repeated_prepend() {
|
||||||
.pipe_in_fixture(INPUT)
|
.pipe_in_fixture(INPUT)
|
||||||
.run()
|
.run()
|
||||||
.stdout_is_fixture("sorted-all-repeated-prepend.expected");
|
.stdout_is_fixture("sorted-all-repeated-prepend.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--all-repeated=prepen"]) // spell-checker:disable-line
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("sorted-all-repeated-prepend.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--all-repeated=p"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("sorted-all-repeated-prepend.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -253,6 +288,11 @@ fn test_group_prepend() {
|
||||||
.pipe_in_fixture(INPUT)
|
.pipe_in_fixture(INPUT)
|
||||||
.run()
|
.run()
|
||||||
.stdout_is_fixture("group-prepend.expected");
|
.stdout_is_fixture("group-prepend.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--group=p"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("group-prepend.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -262,6 +302,11 @@ fn test_group_append() {
|
||||||
.pipe_in_fixture(INPUT)
|
.pipe_in_fixture(INPUT)
|
||||||
.run()
|
.run()
|
||||||
.stdout_is_fixture("group-append.expected");
|
.stdout_is_fixture("group-append.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--group=a"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("group-append.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -271,6 +316,16 @@ fn test_group_both() {
|
||||||
.pipe_in_fixture(INPUT)
|
.pipe_in_fixture(INPUT)
|
||||||
.run()
|
.run()
|
||||||
.stdout_is_fixture("group-both.expected");
|
.stdout_is_fixture("group-both.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--group=bot"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("group-both.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--group=b"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("group-both.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -280,6 +335,11 @@ fn test_group_separate() {
|
||||||
.pipe_in_fixture(INPUT)
|
.pipe_in_fixture(INPUT)
|
||||||
.run()
|
.run()
|
||||||
.stdout_is_fixture("group.expected");
|
.stdout_is_fixture("group.expected");
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["--group=s"])
|
||||||
|
.pipe_in_fixture(INPUT)
|
||||||
|
.run()
|
||||||
|
.stdout_is_fixture("group.expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue