Skip to content

Commit a1ad9c6

Browse files
committed
add quite flag
1 parent 51f2a40 commit a1ad9c6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ struct Cli {
3737
/// only ASCII delimiters are supported.
3838
#[structopt(long, short = "d", default_value = ",")]
3939
delimiter: char,
40+
/// If set benchmark output and progress bar are suppressed.
41+
#[structopt(long, short = "q")]
42+
quiet: bool,
4043
}
4144

4245
/// IO argument for CLI tools which can either take a file or STDIN/STDOUT.
@@ -81,7 +84,7 @@ fn main() -> Result<(), Error> {
8184
//
8285
// We keep this in top level scope, since we want the progress bar to live during the whole
8386
// program execution, so it will be displayed.
84-
let progress_bar = if args.input.is_file() && (args.output.is_file() || isnt(Stream::Stdout)) {
87+
let progress_bar = if !args.quiet && args.input.is_file() && (args.output.is_file() || isnt(Stream::Stdout)) {
8588
let progress_bar = ProgressBar::new(0);
8689
let fmt = "{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})";
8790
progress_bar.set_style(
@@ -168,7 +171,11 @@ fn main() -> Result<(), Error> {
168171
// Drop progress bar, so it's removed from stderr before we print the performance metrics.
169172
// Otherwise, the drop handler would erroneously remove the lower lines of the performance metrics output.
170173
std::mem::drop(progress_bar);
171-
print_performance_metrics(&initial_time, num_records);
174+
175+
if !args.quiet {
176+
print_performance_metrics(&initial_time, num_records);
177+
}
178+
172179
Ok(())
173180
}
174181

0 commit comments

Comments
 (0)