Skip to content

Commit

Permalink
Merge pull request uutils#5392 from zhitkoff/split-undocumented-opt-a…
Browse files Browse the repository at this point in the history
…liases

`split`: undocumented options aliases + help fix
  • Loading branch information
sylvestre committed Oct 11, 2023
2 parents 0a7fe3c + a920464 commit f76b53d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/uu/split/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ pub fn uu_app() -> Command {
.arg(
Arg::new(OPT_NUMERIC_SUFFIXES)
.long(OPT_NUMERIC_SUFFIXES)
.alias("numeric")
.require_equals(true)
.default_missing_value("0")
.num_args(0..=1)
Expand Down Expand Up @@ -338,6 +339,7 @@ pub fn uu_app() -> Command {
.arg(
Arg::new(OPT_HEX_SUFFIXES)
.long(OPT_HEX_SUFFIXES)
.alias("hex")
.default_missing_value("0")
.require_equals(true)
.num_args(0..=1)
Expand Down Expand Up @@ -372,7 +374,7 @@ pub fn uu_app() -> Command {
.allow_hyphen_values(true)
.value_name("SEP")
.action(ArgAction::Append)
.help("use SEP instead of newline as the record separator; '\0' (zero) specifies the NUL character"),
.help("use SEP instead of newline as the record separator; '\\0' (zero) specifies the NUL character"),
)
.arg(
Arg::new(OPT_IO)
Expand Down
26 changes: 26 additions & 0 deletions tests/by-util/test_split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,19 @@ fn test_numeric_suffix() {
assert_eq!(at.read("x12"), "");
}

#[test]
fn test_numeric_suffix_alias() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-n", "4", "--numeric=9", "threebytes.txt"])
.succeeds()
.no_stdout()
.no_stderr();
assert_eq!(at.read("x09"), "a");
assert_eq!(at.read("x10"), "b");
assert_eq!(at.read("x11"), "c");
assert_eq!(at.read("x12"), "");
}

#[test]
fn test_hex_suffix() {
let (at, mut ucmd) = at_and_ucmd!();
Expand All @@ -1205,6 +1218,19 @@ fn test_hex_suffix() {
assert_eq!(at.read("x0c"), "");
}

#[test]
fn test_hex_suffix_alias() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-n", "4", "--hex=9", "threebytes.txt"])
.succeeds()
.no_stdout()
.no_stderr();
assert_eq!(at.read("x09"), "a");
assert_eq!(at.read("x0a"), "b");
assert_eq!(at.read("x0b"), "c");
assert_eq!(at.read("x0c"), "");
}

#[test]
fn test_numeric_suffix_no_equal() {
new_ucmd!()
Expand Down

0 comments on commit f76b53d

Please sign in to comment.