mirror of
https://github.com/uutils/findutils.git
synced 2026-06-10 15:48:30 -07:00
Merge pull request #343 from cakebaker/xargs_max_lines
xargs: add --max-lines
This commit is contained in:
@@ -774,6 +774,7 @@ fn do_xargs(args: &[&str]) -> Result<CommandResult, XargsError> {
|
||||
.arg(
|
||||
Arg::new(options::MAX_LINES)
|
||||
.short('L')
|
||||
.long(options::MAX_LINES)
|
||||
.help(
|
||||
"Set the max number of lines from stdin to be passed to each \
|
||||
command invocation (mutually exclusive with -n)",
|
||||
|
||||
+10
-8
@@ -114,14 +114,16 @@ fn xargs_max_args() {
|
||||
|
||||
#[test]
|
||||
fn xargs_max_lines() {
|
||||
Command::cargo_bin("xargs")
|
||||
.expect("found binary")
|
||||
.args(["-L2"])
|
||||
.write_stdin("ab cd\nef\ngh i\n\njkl\n")
|
||||
.assert()
|
||||
.success()
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::str::diff("ab cd ef\ngh i jkl\n"));
|
||||
for arg in ["-L2", "--max-lines=2"] {
|
||||
Command::cargo_bin("xargs")
|
||||
.expect("found binary")
|
||||
.arg(arg)
|
||||
.write_stdin("ab cd\nef\ngh i\n\njkl\n")
|
||||
.assert()
|
||||
.success()
|
||||
.stderr(predicate::str::is_empty())
|
||||
.stdout(predicate::str::diff("ab cd ef\ngh i jkl\n"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user