mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 09:48:03 +00:00
Merge pull request #2872 from jfinkels/split-verbose
split: add --verbose option
This commit is contained in:
commit
516bdfcfd5
2 changed files with 32 additions and 2 deletions
|
@ -230,7 +230,6 @@ impl Strategy {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct Settings {
|
||||
prefix: String,
|
||||
numeric_suffix: bool,
|
||||
|
@ -240,7 +239,7 @@ struct Settings {
|
|||
/// When supplied, a shell command to output to instead of xaa, xab …
|
||||
filter: Option<String>,
|
||||
strategy: Strategy,
|
||||
verbose: bool, // TODO: warning: field is never read: `verbose`
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
trait Splitter {
|
||||
|
@ -396,6 +395,21 @@ fn split(settings: Settings) -> UResult<()> {
|
|||
break;
|
||||
}
|
||||
|
||||
// TODO It is silly to have the "creating file" message here
|
||||
// after the file has been already created. However, because
|
||||
// of the way the main loop has been written, an extra file
|
||||
// gets created and then deleted in the last iteration of the
|
||||
// loop. So we need to make sure we are not in that case when
|
||||
// printing this message.
|
||||
//
|
||||
// This is only here temporarily while we make some
|
||||
// improvements to the architecture of the main loop in this
|
||||
// function. In the future, it will move to a more appropriate
|
||||
// place---at the point where the file is actually created.
|
||||
if settings.verbose {
|
||||
println!("creating file {}", filename.quote());
|
||||
}
|
||||
|
||||
fileno += 1;
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -408,3 +408,19 @@ fn test_suffixes_exhausted() {
|
|||
.fails()
|
||||
.stderr_only("split: output file suffixes exhausted");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_verbose() {
|
||||
new_ucmd!()
|
||||
.args(&["-b", "5", "--verbose", "asciilowercase.txt"])
|
||||
.succeeds()
|
||||
.stdout_only(
|
||||
"creating file 'xaa'
|
||||
creating file 'xab'
|
||||
creating file 'xac'
|
||||
creating file 'xad'
|
||||
creating file 'xae'
|
||||
creating file 'xaf'
|
||||
",
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue