Optimize: Do not attempt to print if output is a pipe

This is a small optimization so that we do not print the information if
the output is a pipe anyways.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-02-04 00:01:57 +01:00
parent f1a639ea8c
commit c8e74193b3

View file

@ -288,6 +288,7 @@ fn find(rt: &Runtime) {
})
.enumerate();
if !rt.output_is_pipe() {
if scmd.is_present("json") {
let v : Vec<DeserVcard> = iterator.map(|(_, tlp)| tlp.1).collect();
@ -335,6 +336,9 @@ fn find(rt: &Runtime) {
.unwrap_or_exit();
});
}
} else { // if not printing, we still have to consume the iterator to report the touched IDs
let _ = iterator.collect::<Vec<_>>();
}
}
fn get_contact_print_format(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches) -> Handlebars {