From 3a6443b3ef97982da46775c26e8870a0cfbf4093 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 29 Sep 2018 18:42:38 +0200 Subject: [PATCH] Add ID reporting in imag-ids Signed-off-by: Matthias Beyer --- bin/core/imag-ids/src/main.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/bin/core/imag-ids/src/main.rs b/bin/core/imag-ids/src/main.rs index b9afc55a..56c31026 100644 --- a/bin/core/imag-ids/src/main.rs +++ b/bin/core/imag-ids/src/main.rs @@ -89,7 +89,8 @@ fn main() { id_filters::header_filter_lang::parse(&query) }); - if rt.ids_from_stdin() { + let iterator = if rt.ids_from_stdin() { + debug!("Fetching IDs from stdin..."); let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1); Box::new(ids.into_iter().map(Ok)) as Box>> @@ -118,11 +119,20 @@ fn main() { id } else { id.without_base() - }) - .for_each(|id| { - let _ = writeln!(rt.stdout(), "{}", id.to_str().map_err_trace_exit_unwrap(1)) - .to_exit_code() - .unwrap_or_exit(); }); + + let mut stdout = rt.stdout(); + trace!("Got output: {:?}", stdout); + + iterator.for_each(|id| { + rt.report_touched(&id).map_err_trace_exit_unwrap(1); + if !rt.output_is_pipe() { + let id = id.to_str().map_err_trace_exit_unwrap(1); + trace!("Writing to {:?}", stdout); + let _ = writeln!(stdout, "{}", id) + .to_exit_code() + .unwrap_or_exit(); + } + }) }