numfmt: allow hyphen values for --field option

This commit is contained in:
Daniel Hofstetter 2022-10-29 16:50:41 +02:00
parent 4b2138e61e
commit 3a8feedf2d
2 changed files with 9 additions and 0 deletions

View file

@ -275,6 +275,7 @@ pub fn uu_app() -> Command {
.long(options::FIELD)
.help("replace the numbers in these input fields; see FIELDS below")
.value_name("FIELDS")
.allow_hyphen_values(true)
.default_value(options::FIELD_DEFAULT),
)
.arg(

View file

@ -375,6 +375,14 @@ fn test_format_selected_fields() {
.stdout_only("1000 2K 3000 4000 5K 6K\n");
}
#[test]
fn test_format_implied_range_and_field() {
new_ucmd!()
.args(&["--from=auto", "--field", "-2,4", "1K 2K 3K 4K 5K 6K"])
.succeeds()
.stdout_only("1000 2000 3K 4000 5K 6K\n");
}
#[test]
fn test_should_succeed_if_selected_field_out_of_range() {
new_ucmd!()