summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-todo/src/lib.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-03-01 18:40:35 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-03-01 20:35:45 +0100
commitb48c45ec4ba26ed987e60ddd1b5e0c32f1225463 (patch)
tree6673f1fd15df360727dd15a42510ab8d40dc6848 /bin/domain/imag-todo/src/lib.rs
parent6c0e983a816dcb02e85ed1fb16f24ad94ac098b4 (diff)
downloadimag-b48c45ec4ba26ed987e60ddd1b5e0c32f1225463.tar.gz
imag-b48c45ec4ba26ed987e60ddd1b5e0c32f1225463.tar.xz
Diffstat (limited to 'bin/domain/imag-todo/src/lib.rs')
-rw-r--r--bin/domain/imag-todo/src/lib.rs34
1 files changed, 16 insertions, 18 deletions
diff --git a/bin/domain/imag-todo/src/lib.rs b/bin/domain/imag-todo/src/lib.rs
index f8611200..cc17a1db 100644
--- a/bin/domain/imag-todo/src/lib.rs
+++ b/bin/domain/imag-todo/src/lib.rs
@@ -86,6 +86,7 @@ use prettytable::Row;
use libimagentryedit::edit::Edit;
use libimagentryview::viewer::Viewer;
+use libimagentryview::viewer::IntoViewIter;
use libimagrt::application::ImagApplication;
use libimagrt::runtime::Runtime;
use libimagstore::iter::get::*;
@@ -95,6 +96,7 @@ use libimagtodo::entry::Todo;
use libimagtodo::priority::Priority;
use libimagtodo::status::Status;
use libimagtodo::store::TodoStore;
+use libimagrt::runtime::IntoTouchIterator;
mod ui;
mod import;
@@ -241,7 +243,6 @@ fn mark(rt: &Runtime) -> Result<()> {
///
/// Supports filtering of todos by status using the passed in StatusMatcher
fn list_todos(rt: &Runtime, matcher: &StatusMatcher, show_hidden: bool) -> Result<()> {
- use filters::failable::filter::FailableFilter;
debug!("Listing todos with status filter {:?}", matcher);
struct TodoViewer {
@@ -315,24 +316,21 @@ fn list_todos(rt: &Runtime, matcher: &StatusMatcher, show_hidden: bool) -> Resul
}
}
})
- .and_then_ok(|entry| {
- trace!("Processing {}", entry.get_location());
- if (!rt.output_is_pipe() || rt.output_data_pipe()) && (show_hidden || filter_hidden.filter(&entry)?) {
- trace!("Printing {}", entry.get_location());
- if let Err(e) = viewer.view_entry(&entry, &mut rt.stdout()) {
- use libimagentryview::error::Error;
- match e {
- Error::Other(e) => return Err(e),
- Error::Io(e) => if e.kind() != std::io::ErrorKind::BrokenPipe {
- return Err(failure::Error::from(e))
- },
- }
- }
- }
-
- rt.report_touched(entry.get_location())
+ .inspect(|e| trace!("Processing: {:?}", e))
+ .filter_map(|r| match r {
+ Err(err) => Some(Err(err)),
+ Ok(entry) => match filter_hidden(&entry).map(|b| b || show_hidden) {
+ Ok(true) => Some(Ok(entry)),
+ Ok(false) => None,
+ Err(err) => Some(Err(err)),
+ },
})
- .collect()
+ .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() {