summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-04-06 17:55:33 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-04-13 12:23:46 +0200
commitf2b0e6581497957c95e8b8188d962d1445695653 (patch)
tree6a4ba7fe8fc19460586a7452f05770b6e9aa70a7
parent694a47ae5e2756e1518b829829c46f801df7c2ac (diff)
Fix: Do not print data if output is pipe, except if that behaviour is overridden
Signed-off-by: Matthias Beyer <mail@beyermatthias.de> Fixes: b48c45ec4ba2 ("Change implementation to use the iterator extensions")
-rw-r--r--bin/domain/imag-todo/src/lib.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/bin/domain/imag-todo/src/lib.rs b/bin/domain/imag-todo/src/lib.rs
index db93004d..2b960650 100644
--- a/bin/domain/imag-todo/src/lib.rs
+++ b/bin/domain/imag-todo/src/lib.rs
@@ -308,7 +308,7 @@ fn list_todos(rt: &Runtime, matcher: &StatusMatcher, show_hidden: bool) -> Resul
Ok(todo.get_hidden()?.map(|hid| hid > now).unwrap_or(true))
};
- iter
+ let iter = iter
.filter_map(|r| {
match r.and_then(|e| e.get_status().map(|s| (s, e))) {
Err(e) => Some(Err(e)),
@@ -327,13 +327,21 @@ fn list_todos(rt: &Runtime, matcher: &StatusMatcher, show_hidden: bool) -> Resul
Ok(false) => None,
Err(err) => Some(Err(err)),
},
- })
- .view_all_if(viewer, &mut rt.stdout(), |r| r.as_ref().ok())
- .and_then_ok(|e| e)
- .report_entries_touched(rt, |r| r.as_ref().ok().map(|e| e.get_location().clone()))
- .and_then_ok(|e| e)
- .collect::<Result<Vec<FileLockEntry>>>()
- .map(|_| ())
+ });
+
+ if rt.output_is_pipe() && !rt.output_data_pipe() {
+ iter.report_entries_touched(rt, |r| r.as_ref().ok().map(|e| e.get_location().clone()))
+ .and_then_ok(|e| e)
+ .collect::<Result<Vec<FileLockEntry>>>()
+ .map(|_| ())
+ } else {
+ iter.view_all_if(viewer, &mut rt.stdout(), |r| r.as_ref().ok())
+ .and_then_ok(|e| e)
+ .report_entries_touched(rt, |r| r.as_ref().ok().map(|e| e.get_location().clone()))
+ .and_then_ok(|e| e)
+ .collect::<Result<Vec<FileLockEntry>>>()
+ .map(|_| ())
+ }
};
if rt.ids_from_stdin() {