mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
wc: accept shortcuts for stringly-enum arguments
This commit is contained in:
parent
a699bfd1fb
commit
91679fc747
2 changed files with 26 additions and 1 deletions
|
@ -29,6 +29,7 @@ use uucore::{
|
|||
error::{FromIo, UError, UResult},
|
||||
format_usage, help_about, help_usage,
|
||||
quoting_style::{escape_name, QuotingStyle},
|
||||
shortcut_value_parser::ShortcutValueParser,
|
||||
show,
|
||||
};
|
||||
|
||||
|
@ -439,7 +440,9 @@ pub fn uu_app() -> Command {
|
|||
.arg(
|
||||
Arg::new(options::TOTAL)
|
||||
.long(options::TOTAL)
|
||||
.value_parser(["auto", "always", "only", "never"])
|
||||
.value_parser(ShortcutValueParser::new([
|
||||
"auto", "always", "only", "never",
|
||||
]))
|
||||
.value_name("WHEN")
|
||||
.hide_possible_values(true)
|
||||
.help(concat!(
|
||||
|
|
|
@ -531,6 +531,10 @@ fn test_total_auto() {
|
|||
.args(&["lorem_ipsum.txt", "--total=auto"])
|
||||
.run()
|
||||
.stdout_is(" 13 109 772 lorem_ipsum.txt\n");
|
||||
new_ucmd!()
|
||||
.args(&["lorem_ipsum.txt", "--tot=au"])
|
||||
.run()
|
||||
.stdout_is(" 13 109 772 lorem_ipsum.txt\n");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=auto"])
|
||||
|
@ -551,6 +555,13 @@ fn test_total_always() {
|
|||
" 13 109 772 lorem_ipsum.txt\n",
|
||||
" 13 109 772 total\n",
|
||||
));
|
||||
new_ucmd!()
|
||||
.args(&["lorem_ipsum.txt", "--total=al"])
|
||||
.run()
|
||||
.stdout_is(concat!(
|
||||
" 13 109 772 lorem_ipsum.txt\n",
|
||||
" 13 109 772 total\n",
|
||||
));
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=always"])
|
||||
|
@ -576,6 +587,13 @@ fn test_total_never() {
|
|||
" 13 109 772 lorem_ipsum.txt\n",
|
||||
" 18 204 1115 moby_dick.txt\n",
|
||||
));
|
||||
new_ucmd!()
|
||||
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=n"])
|
||||
.run()
|
||||
.stdout_is(concat!(
|
||||
" 13 109 772 lorem_ipsum.txt\n",
|
||||
" 18 204 1115 moby_dick.txt\n",
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -589,6 +607,10 @@ fn test_total_only() {
|
|||
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=only"])
|
||||
.run()
|
||||
.stdout_is("31 313 1887\n");
|
||||
new_ucmd!()
|
||||
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--t=o"])
|
||||
.run()
|
||||
.stdout_is("31 313 1887\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue