mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
fmt: accept repeated arguments
This commit is contained in:
parent
c2d55b4f84
commit
e76f92c212
2 changed files with 29 additions and 2 deletions
|
@ -305,6 +305,7 @@ pub fn uu_app() -> Command {
|
|||
.about(ABOUT)
|
||||
.override_usage(format_usage(USAGE))
|
||||
.infer_long_args(true)
|
||||
.args_override_self(true)
|
||||
.arg(
|
||||
Arg::new(options::CROWN_MARGIN)
|
||||
.short('c')
|
||||
|
|
|
@ -19,7 +19,7 @@ fn test_fmt() {
|
|||
|
||||
#[test]
|
||||
fn test_fmt_quick() {
|
||||
for param in ["-q", "--quick"] {
|
||||
for param in ["-q", "--quick", "-qq"] {
|
||||
new_ucmd!()
|
||||
.args(&["one-word-per-line.txt", param])
|
||||
.succeeds()
|
||||
|
@ -35,6 +35,10 @@ fn test_fmt_width() {
|
|||
.succeeds()
|
||||
.stdout_is("this is a\nfile with\none word\nper line\n");
|
||||
}
|
||||
new_ucmd!()
|
||||
.args(&["one-word-per-line.txt", "-w50", "--width", "10"])
|
||||
.succeeds()
|
||||
.stdout_is("this is a\nfile with\none word\nper line\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -66,6 +70,11 @@ fn test_fmt_width_too_big() {
|
|||
.code_is(1)
|
||||
.stderr_is("fmt: invalid width: '2501': Numerical result out of range\n");
|
||||
}
|
||||
// However, as a temporary value it is okay:
|
||||
new_ucmd!()
|
||||
.args(&["one-word-per-line.txt", "-w2501", "--width", "10"])
|
||||
.succeeds()
|
||||
.stdout_is("this is a\nfile with\none word\nper line\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -97,7 +106,7 @@ fn test_fmt_width_not_valid_number() {
|
|||
.stderr_contains("fmt: invalid width: '25x'");
|
||||
}
|
||||
|
||||
#[ignore]
|
||||
#[ignore = "our 'goal' algorithm is very different from GNU; fix this!"]
|
||||
#[test]
|
||||
fn test_fmt_goal() {
|
||||
for param in ["-g", "--goal"] {
|
||||
|
@ -106,6 +115,10 @@ fn test_fmt_goal() {
|
|||
.succeeds()
|
||||
.stdout_is("this is a\nfile with one\nword per line\n");
|
||||
}
|
||||
new_ucmd!()
|
||||
.args(&["one-word-per-line.txt", "-g40", "-g7"])
|
||||
.succeeds()
|
||||
.stdout_is("this is a\nfile with one\nword per line\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -130,6 +143,19 @@ fn test_fmt_goal_bigger_than_default_width_of_75() {
|
|||
}
|
||||
}
|
||||
|
||||
#[ignore = "our 'goal' algorithm is very different from GNU; fix this!"]
|
||||
#[test]
|
||||
fn test_fmt_too_big_goal_sometimes_okay() {
|
||||
new_ucmd!()
|
||||
.args(&["one-word-per-line.txt", "--width=75", "-g76", "-g10"])
|
||||
.succeeds()
|
||||
.stdout_is("this is a\nfile with one\nword per line\n");
|
||||
new_ucmd!()
|
||||
.args(&["one-word-per-line.txt", "-g76", "-g10"])
|
||||
.succeeds()
|
||||
.stdout_is("this is a\nfile with one\nword per line\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fmt_non_existent_file() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue