diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2018-03-02 21:28:40 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2018-03-02 21:28:40 +0100 |
commit | affd15a890e233af193d92678b9c97ecfb897b0c (patch) | |
tree | 837f6037a4313a607ef14826dc02425456da1773 /bin/domain/imag-diary/src/view.rs | |
parent | 8c37fb865abf30d8942c44182f95c172934a6fdd (diff) |
Rewrite imag-diary for new Diary::entries() interface
Diffstat (limited to 'bin/domain/imag-diary/src/view.rs')
-rw-r--r-- | bin/domain/imag-diary/src/view.rs | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/bin/domain/imag-diary/src/view.rs b/bin/domain/imag-diary/src/view.rs index 7752c693..66a952c0 100644 --- a/bin/domain/imag-diary/src/view.rs +++ b/bin/domain/imag-diary/src/view.rs @@ -22,6 +22,7 @@ use libimagdiary::viewer::DiaryViewer as DV; use libimagrt::runtime::Runtime; use libimagerror::trace::MapErrTrace; use libimagutil::warn_exit::warn_exit; +use libimagstore::iter::get::StoreIdGetIteratorExtension; use util::get_diary_name; @@ -29,9 +30,16 @@ pub fn view(rt: &Runtime) { let diaryname = get_diary_name(rt).unwrap_or_else(|| warn_exit("No diary name", 1)); let hdr = rt.cli().subcommand_matches("view").unwrap().is_present("show-header"); - Diary::entries(rt.store(), &diaryname) - .and_then(|entries| DV::new(hdr).view_entries(entries.into_iter().filter_map(Result::ok))) - .map_err_trace() - .ok(); + let entries = Diary::entries(rt.store(), &diaryname) + .map_err_trace_exit_unwrap(1) + .into_get_iter(rt.store()) + .filter_map(Result::ok) + .map(|e| e.unwrap_or_else(|| { + error!("Failed to fetch entry"); + ::std::process::exit(1) + })); + + DV::new(hdr).view_entries(entries) + .map_err_trace_exit_unwrap(1); } |