mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
numfmt: accept shortcuts for stringly-enum arguments
This commit is contained in:
parent
3877d14504
commit
2646944bee
2 changed files with 12 additions and 1 deletions
|
@ -15,6 +15,7 @@ use units::{IEC_BASES, SI_BASES};
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::UResult;
|
use uucore::error::UResult;
|
||||||
use uucore::ranges::Range;
|
use uucore::ranges::Range;
|
||||||
|
use uucore::shortcut_value_parser::ShortcutValueParser;
|
||||||
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error};
|
use uucore::{format_usage, help_about, help_section, help_usage, show, show_error};
|
||||||
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
|
@ -340,7 +341,13 @@ pub fn uu_app() -> Command {
|
||||||
.help("use METHOD for rounding when scaling")
|
.help("use METHOD for rounding when scaling")
|
||||||
.value_name("METHOD")
|
.value_name("METHOD")
|
||||||
.default_value("from-zero")
|
.default_value("from-zero")
|
||||||
.value_parser(["up", "down", "from-zero", "towards-zero", "nearest"]),
|
.value_parser(ShortcutValueParser::new([
|
||||||
|
"up",
|
||||||
|
"down",
|
||||||
|
"from-zero",
|
||||||
|
"towards-zero",
|
||||||
|
"nearest",
|
||||||
|
])),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::SUFFIX)
|
Arg::new(options::SUFFIX)
|
||||||
|
|
|
@ -550,10 +550,14 @@ fn test_delimiter_with_padding_and_fields() {
|
||||||
fn test_round() {
|
fn test_round() {
|
||||||
for (method, exp) in [
|
for (method, exp) in [
|
||||||
("from-zero", ["9.1K", "-9.1K", "9.1K", "-9.1K"]),
|
("from-zero", ["9.1K", "-9.1K", "9.1K", "-9.1K"]),
|
||||||
|
("from-zer", ["9.1K", "-9.1K", "9.1K", "-9.1K"]), // spell-checker:disable-line
|
||||||
|
("f", ["9.1K", "-9.1K", "9.1K", "-9.1K"]),
|
||||||
("towards-zero", ["9.0K", "-9.0K", "9.0K", "-9.0K"]),
|
("towards-zero", ["9.0K", "-9.0K", "9.0K", "-9.0K"]),
|
||||||
("up", ["9.1K", "-9.0K", "9.1K", "-9.0K"]),
|
("up", ["9.1K", "-9.0K", "9.1K", "-9.0K"]),
|
||||||
("down", ["9.0K", "-9.1K", "9.0K", "-9.1K"]),
|
("down", ["9.0K", "-9.1K", "9.0K", "-9.1K"]),
|
||||||
("nearest", ["9.0K", "-9.0K", "9.1K", "-9.1K"]),
|
("nearest", ["9.0K", "-9.0K", "9.1K", "-9.1K"]),
|
||||||
|
("near", ["9.0K", "-9.0K", "9.1K", "-9.1K"]),
|
||||||
|
("n", ["9.0K", "-9.0K", "9.1K", "-9.1K"]),
|
||||||
] {
|
] {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&[
|
.args(&[
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue