mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
uniq: accept shortcuts for stringly-enum arguments
This commit is contained in:
@@ -14,6 +14,7 @@ use std::num::IntErrorKind;
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UError, UResult, USimpleError};
|
||||
use uucore::posix::{posix_version, OBSOLETE};
|
||||
use uucore::shortcut_value_parser::ShortcutValueParser;
|
||||
use uucore::{format_usage, help_about, help_section, help_usage};
|
||||
|
||||
const ABOUT: &str = help_about!("uniq.md");
|
||||
@@ -609,11 +610,11 @@ pub fn uu_app() -> Command {
|
||||
Arg::new(options::ALL_REPEATED)
|
||||
.short('D')
|
||||
.long(options::ALL_REPEATED)
|
||||
.value_parser([
|
||||
.value_parser(ShortcutValueParser::new([
|
||||
"none",
|
||||
"prepend",
|
||||
"separate"
|
||||
])
|
||||
]))
|
||||
.help("print all duplicate lines. Delimiting is done with blank lines. [default: none]")
|
||||
.value_name("delimit-method")
|
||||
.num_args(0..=1)
|
||||
@@ -623,12 +624,12 @@ pub fn uu_app() -> Command {
|
||||
.arg(
|
||||
Arg::new(options::GROUP)
|
||||
.long(options::GROUP)
|
||||
.value_parser([
|
||||
.value_parser(ShortcutValueParser::new([
|
||||
"separate",
|
||||
"prepend",
|
||||
"append",
|
||||
"both",
|
||||
])
|
||||
]))
|
||||
.help("show all items, separating groups with an empty line. [default: separate]")
|
||||
.value_name("group-method")
|
||||
.num_args(0..=1)
|
||||
|
||||
@@ -145,6 +145,21 @@ fn test_stdin_all_repeated() {
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.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]
|
||||
@@ -167,6 +182,16 @@ fn test_stdin_all_repeated_separate() {
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.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]
|
||||
@@ -176,6 +201,16 @@ fn test_stdin_all_repeated_prepend() {
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.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]
|
||||
@@ -253,6 +288,11 @@ fn test_group_prepend() {
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.stdout_is_fixture("group-prepend.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--group=p"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.stdout_is_fixture("group-prepend.expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -262,6 +302,11 @@ fn test_group_append() {
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.stdout_is_fixture("group-append.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--group=a"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.stdout_is_fixture("group-append.expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -271,6 +316,16 @@ fn test_group_both() {
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.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]
|
||||
@@ -280,6 +335,11 @@ fn test_group_separate() {
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.stdout_is_fixture("group.expected");
|
||||
new_ucmd!()
|
||||
.args(&["--group=s"])
|
||||
.pipe_in_fixture(INPUT)
|
||||
.run()
|
||||
.stdout_is_fixture("group.expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user