@@ -37,6 +37,9 @@ struct Cli {
37
37
/// only ASCII delimiters are supported.
38
38
#[ structopt( long, short = "d" , default_value = "," ) ]
39
39
delimiter : char ,
40
+ /// If set benchmark output and progress bar are suppressed.
41
+ #[ structopt( long, short = "q" ) ]
42
+ quiet : bool ,
40
43
}
41
44
42
45
/// IO argument for CLI tools which can either take a file or STDIN/STDOUT.
@@ -81,7 +84,7 @@ fn main() -> Result<(), Error> {
81
84
//
82
85
// We keep this in top level scope, since we want the progress bar to live during the whole
83
86
// 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 ) ) {
85
88
let progress_bar = ProgressBar :: new ( 0 ) ;
86
89
let fmt = "{spinner:.green} [{elapsed_precise}] [{wide_bar:.cyan/blue}] {bytes}/{total_bytes} ({eta})" ;
87
90
progress_bar. set_style (
@@ -168,7 +171,11 @@ fn main() -> Result<(), Error> {
168
171
// Drop progress bar, so it's removed from stderr before we print the performance metrics.
169
172
// Otherwise, the drop handler would erroneously remove the lower lines of the performance metrics output.
170
173
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
+
172
179
Ok ( ( ) )
173
180
}
174
181
0 commit comments