mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37: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},
|
error::{FromIo, UError, UResult},
|
||||||
format_usage, help_about, help_usage,
|
format_usage, help_about, help_usage,
|
||||||
quoting_style::{escape_name, QuotingStyle},
|
quoting_style::{escape_name, QuotingStyle},
|
||||||
|
shortcut_value_parser::ShortcutValueParser,
|
||||||
show,
|
show,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -439,7 +440,9 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::TOTAL)
|
Arg::new(options::TOTAL)
|
||||||
.long(options::TOTAL)
|
.long(options::TOTAL)
|
||||||
.value_parser(["auto", "always", "only", "never"])
|
.value_parser(ShortcutValueParser::new([
|
||||||
|
"auto", "always", "only", "never",
|
||||||
|
]))
|
||||||
.value_name("WHEN")
|
.value_name("WHEN")
|
||||||
.hide_possible_values(true)
|
.hide_possible_values(true)
|
||||||
.help(concat!(
|
.help(concat!(
|
||||||
|
|
|
@ -531,6 +531,10 @@ fn test_total_auto() {
|
||||||
.args(&["lorem_ipsum.txt", "--total=auto"])
|
.args(&["lorem_ipsum.txt", "--total=auto"])
|
||||||
.run()
|
.run()
|
||||||
.stdout_is(" 13 109 772 lorem_ipsum.txt\n");
|
.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!()
|
new_ucmd!()
|
||||||
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=auto"])
|
.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 lorem_ipsum.txt\n",
|
||||||
" 13 109 772 total\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!()
|
new_ucmd!()
|
||||||
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=always"])
|
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=always"])
|
||||||
|
@ -576,6 +587,13 @@ fn test_total_never() {
|
||||||
" 13 109 772 lorem_ipsum.txt\n",
|
" 13 109 772 lorem_ipsum.txt\n",
|
||||||
" 18 204 1115 moby_dick.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]
|
#[test]
|
||||||
|
@ -589,6 +607,10 @@ fn test_total_only() {
|
||||||
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=only"])
|
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=only"])
|
||||||
.run()
|
.run()
|
||||||
.stdout_is("31 313 1887\n");
|
.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]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue