diff --git a/bin/core/imag-gps/src/main.rs b/bin/core/imag-gps/src/main.rs index fe57dc1f..ac673062 100644 --- a/bin/core/imag-gps/src/main.rs +++ b/bin/core/imag-gps/src/main.rs @@ -138,9 +138,7 @@ fn add(rt: &Runtime) { .set_coordinates(c.clone()) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(&id) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); }); } @@ -175,9 +173,7 @@ fn remove(rt: &Runtime) { let _ = writeln!(rt.stdout(), "{}", removed_value).to_exit_code().unwrap_or_exit(); } - let _ = rt - .report_touched(&id) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); }); } @@ -204,9 +200,7 @@ fn get(rt: &Runtime) { let _ = writeln!(stdout, "{}", value).to_exit_code().unwrap_or_exit(); - let _ = rt - .report_touched(&id) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); }) } diff --git a/bin/core/imag-grep/src/main.rs b/bin/core/imag-grep/src/main.rs index 2afefd30..9ab3c29d 100644 --- a/bin/core/imag-grep/src/main.rs +++ b/bin/core/imag-grep/src/main.rs @@ -125,8 +125,6 @@ fn show(rt: &Runtime, e: &Entry, re: &Regex, opts: &Options, count: &mut usize) *count += 1; } - let _ = rt - .report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(); } diff --git a/bin/core/imag-ids/src/main.rs b/bin/core/imag-ids/src/main.rs index 1e9a54fa..2985b133 100644 --- a/bin/core/imag-ids/src/main.rs +++ b/bin/core/imag-ids/src/main.rs @@ -127,11 +127,12 @@ fn main() { trace!("Got output: {:?}", stdout); iterator.for_each(|id| { - rt.report_touched(&id).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); // .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) + writeln!(stdout, "{}", id) .to_exit_code() .unwrap_or_exit(); } diff --git a/bin/core/imag-link/src/main.rs b/bin/core/imag-link/src/main.rs index 833e4871..79f70a43 100644 --- a/bin/core/imag-link/src/main.rs +++ b/bin/core/imag-link/src/main.rs @@ -164,7 +164,7 @@ fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I) .map_err_trace_exit_unwrap(1) .into_iter(); - let _ = rt.report_all_touched(iter).map_err_trace_exit_unwrap(1); + let _ = rt.report_all_touched(iter).unwrap_or_exit(); } else { debug!("Linking internally: {:?} -> {:?}", from, entry); @@ -187,18 +187,14 @@ fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I) .add_internal_link(&mut to_entry) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(to_entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(to_entry.get_location()).unwrap_or_exit(); } info!("Ok: {} -> {}", from, entry); } - let _ = rt - .report_touched(from_entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(from_entry.get_location()).unwrap_or_exit(); } fn remove_linking(rt: &Runtime) { @@ -226,9 +222,7 @@ fn remove_linking(rt: &Runtime) { .remove_internal_link(&mut from) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(to_entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(to_entry.get_location()).unwrap_or_exit(); }, Ok(None) => { // looks like this is not an entry, but a filesystem URI and therefor an @@ -250,9 +244,7 @@ fn remove_linking(rt: &Runtime) { } }); - let _ = rt - .report_touched(from.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(from.get_location()).unwrap_or_exit(); } fn unlink(rt: &Runtime) { @@ -267,9 +259,7 @@ fn unlink(rt: &Runtime) { .unlink(rt.store()) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(&id) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); }); } @@ -323,18 +313,14 @@ fn list_linkings(rt: &Runtime) { }) } - let _ = rt - .report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); }, Ok(None) => warn!("Not found: {}", id), Err(e) => trace_error(&e), } - let _ = rt - .report_touched(&id) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); }); if !list_plain { diff --git a/bin/core/imag-mv/src/main.rs b/bin/core/imag-mv/src/main.rs index d0611210..118f609e 100644 --- a/bin/core/imag-mv/src/main.rs +++ b/bin/core/imag-mv/src/main.rs @@ -52,6 +52,7 @@ use std::path::PathBuf; use libimagrt::setup::generate_runtime_setup; use libimagerror::trace::MapErrTrace; use libimagerror::iter::TraceIterator; +use libimagerror::exit::ExitUnwrap; use libimagstore::storeid::StoreId; use libimagstore::store::Store; use libimagstore::store::FileLockEntry; @@ -131,8 +132,7 @@ fn main() { }) .map_err_trace_exit_unwrap(1); - let _ = rt.report_touched(&destname) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&destname).unwrap_or_exit(); // re-add links to moved entry relink(rt.store(), destname, &mut linked_entries); diff --git a/bin/core/imag-ref/src/main.rs b/bin/core/imag-ref/src/main.rs index 2d7e7663..ad72cfec 100644 --- a/bin/core/imag-ref/src/main.rs +++ b/bin/core/imag-ref/src/main.rs @@ -102,7 +102,7 @@ fn deref(rt: &Runtime) { .map(|s| info!("{}", s)) .ok(); // safe here because we exited already in the error case - let _ = rt.report_touched(&id).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); }, None => { error!("No entry for id '{}' found", id); diff --git a/bin/core/imag-store/src/create.rs b/bin/core/imag-store/src/create.rs index fcfc8ec2..527a89fa 100644 --- a/bin/core/imag-store/src/create.rs +++ b/bin/core/imag-store/src/create.rs @@ -63,7 +63,7 @@ pub fn create(rt: &Runtime) { } .map_err_trace_exit_unwrap(1); - let _ = rt.report_touched(&path).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&path).unwrap_or_exit(); } fn create_from_cli_spec(rt: &Runtime, matches: &ArgMatches, path: &StoreId) -> Result<()> { diff --git a/bin/core/imag-store/src/get.rs b/bin/core/imag-store/src/get.rs index 271c722d..2f1cf873 100644 --- a/bin/core/imag-store/src/get.rs +++ b/bin/core/imag-store/src/get.rs @@ -37,7 +37,7 @@ pub fn get(rt: &Runtime) { let _ = match rt.store().get(path.clone()).map_err_trace_exit_unwrap(1) { Some(entry) => { print_entry(rt, scmd, entry); - let _ = rt.report_touched(&path).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&path).unwrap_or_exit(); }, None => info!("No entry found"), }; diff --git a/bin/core/imag-store/src/retrieve.rs b/bin/core/imag-store/src/retrieve.rs index 533e45aa..4a20d33b 100644 --- a/bin/core/imag-store/src/retrieve.rs +++ b/bin/core/imag-store/src/retrieve.rs @@ -48,7 +48,7 @@ pub fn retrieve(rt: &Runtime) { .map_dbg(|e| format!("{:?}", e)) .map_err_trace_exit_unwrap(1); - let _ = rt.report_touched(&path).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&path).unwrap_or_exit(); }); } diff --git a/bin/core/imag-store/src/update.rs b/bin/core/imag-store/src/update.rs index 084788e1..1302f3d1 100644 --- a/bin/core/imag-store/src/update.rs +++ b/bin/core/imag-store/src/update.rs @@ -49,7 +49,7 @@ pub fn update(rt: &Runtime) { debug!("New header set"); } - let _ = rt.report_touched(locked_e.get_location()).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(locked_e.get_location()).unwrap_or_exit(); }); } diff --git a/bin/core/imag-store/src/verify.rs b/bin/core/imag-store/src/verify.rs index cd2f1830..6f2b96a8 100644 --- a/bin/core/imag-store/src/verify.rs +++ b/bin/core/imag-store/src/verify.rs @@ -47,7 +47,7 @@ pub fn verify(rt: &Runtime) { }; info!("{: >6} | {: >14} | {:?}", verify, content_len, p.deref()); - let _ = rt.report_touched(fle.get_location()).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(fle.get_location()).unwrap_or_exit(); status }); diff --git a/bin/core/imag-tag/src/main.rs b/bin/core/imag-tag/src/main.rs index 0aee4af8..982d50ec 100644 --- a/bin/core/imag-tag/src/main.rs +++ b/bin/core/imag-tag/src/main.rs @@ -157,9 +157,7 @@ fn alter(rt: &Runtime, path: StoreId, add: Option>, rem: Option>(); @@ -209,8 +208,7 @@ fn main() { .view_entry(&entry, &mut outlock) .map_err_trace_exit_unwrap(1); - rt.report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + rt.report_touched(entry.get_location()).unwrap_or_exit(); }); } else { let mut viewer = StdoutViewer::new(view_header, !hide_content); @@ -244,8 +242,7 @@ fn main() { .view_entry(&entry, &mut outlock) .map_err_trace_exit_unwrap(1); - rt.report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + rt.report_touched(entry.get_location()).unwrap_or_exit(); }); } } diff --git a/bin/domain/imag-bookmark/src/main.rs b/bin/domain/imag-bookmark/src/main.rs index 7b3237dc..e5c42088 100644 --- a/bin/domain/imag-bookmark/src/main.rs +++ b/bin/domain/imag-bookmark/src/main.rs @@ -101,18 +101,14 @@ fn add(rt: &Runtime) { .ok_or_else(|| format_err!("No bookmark collection '{}' found", coll)) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(collection.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(collection.get_location()).unwrap_or_exit(); for url in scmd.values_of("urls").unwrap() { // unwrap saved by clap let new_ids = collection .add_link(rt.store(), BookmarkLink::from(url)) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_all_touched(new_ids.into_iter()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_all_touched(new_ids.into_iter()).unwrap_or_exit(); } info!("Ready"); @@ -124,7 +120,7 @@ fn collection(rt: &Runtime) { if scmd.is_present("add") { // adding a new collection let name = scmd.value_of("add").unwrap(); if let Ok(id) = BookmarkCollectionStore::new(rt.store(), &name) { - let _ = rt.report_touched(id.get_location()).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(id.get_location()).unwrap_or_exit(); info!("Created: {}", name); } else { warn!("Creating collection {} failed", name); @@ -151,9 +147,7 @@ fn list(rt: &Runtime) { .ok_or_else(|| format_err!("No bookmark collection '{}' found", coll)) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(collection.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(collection.get_location()).unwrap_or_exit(); collection .links(rt.store()) @@ -177,18 +171,14 @@ fn remove(rt: &Runtime) { .ok_or_else(|| format_err!("No bookmark collection '{}' found", coll)) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(collection.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(collection.get_location()).unwrap_or_exit(); for url in scmd.values_of("urls").unwrap() { // enforced by clap let removed_links = collection .remove_link(rt.store(), BookmarkLink::from(url)) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_all_touched(removed_links.into_iter()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_all_touched(removed_links.into_iter()).unwrap_or_exit(); } info!("Ready"); diff --git a/bin/domain/imag-contact/src/create.rs b/bin/domain/imag-contact/src/create.rs index a470cedc..082ed928 100644 --- a/bin/domain/imag-contact/src/create.rs +++ b/bin/domain/imag-contact/src/create.rs @@ -204,8 +204,7 @@ pub fn create(rt: &Runtime) { .create_from_path(&location) .map_err_trace_exit_unwrap(1); - let _ = rt.report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); info!("Created entry in store"); } else { diff --git a/bin/domain/imag-contact/src/main.rs b/bin/domain/imag-contact/src/main.rs index 3385beef..a68ee6a6 100644 --- a/bin/domain/imag-contact/src/main.rs +++ b/bin/domain/imag-contact/src/main.rs @@ -125,8 +125,7 @@ fn list(rt: &Runtime) { .map(|fle| fle.ok_or_else(|| Error::from(err_msg("StoreId not found".to_owned())))) .trace_unwrap_exit(1) .map(|fle| { - let _ = rt.report_touched(fle.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(fle.get_location()).unwrap_or_exit(); fle }) .map(|e| e.deser()) @@ -171,9 +170,7 @@ fn import(rt: &Runtime) { .retrieve_from_path(&path) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); } else if path.is_dir() { for entry in WalkDir::new(path).min_depth(1).into_iter() { let entry = entry @@ -187,9 +184,7 @@ fn import(rt: &Runtime) { .retrieve_from_path(&pb) .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(fle.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(fle.get_location()).unwrap_or_exit(); info!("Imported: {}", entry.path().to_str().unwrap_or("")); } else { warn!("Ignoring non-file: {}", entry.path().to_str().unwrap_or("")); @@ -228,9 +223,7 @@ fn show(rt: &Runtime) { .unwrap() // exited above .starts_with(&hash) { - let _ = rt - .report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); Some(deser) } else { None @@ -285,9 +278,7 @@ fn find(rt: &Runtime) { || card.fullname().iter().any(|a| str_contains_any(a, &grepstring)); if take { - let _ = rt - .report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); // optimization so we don't have to parse again in the next step Some((entry, card)) diff --git a/bin/domain/imag-diary/src/create.rs b/bin/domain/imag-diary/src/create.rs index 788fd33c..7e7c47b2 100644 --- a/bin/domain/imag-diary/src/create.rs +++ b/bin/domain/imag-diary/src/create.rs @@ -45,7 +45,7 @@ pub fn create(rt: &Runtime) { let mut entry = create_entry(rt.store(), &diaryname, rt); - let _ = rt.report_touched(entry.get_location()).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); let res = if rt.cli().subcommand_matches("create").unwrap().is_present("no-edit") { debug!("Not editing new diary entry"); diff --git a/bin/domain/imag-diary/src/delete.rs b/bin/domain/imag-diary/src/delete.rs index 8ce2296a..af719ca7 100644 --- a/bin/domain/imag-diary/src/delete.rs +++ b/bin/domain/imag-diary/src/delete.rs @@ -66,9 +66,7 @@ pub fn delete(rt: &Runtime) { return; } - let _ = rt - .report_touched(&to_del_location) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&to_del_location).unwrap_or_exit(); let _ = rt .store() diff --git a/bin/domain/imag-diary/src/list.rs b/bin/domain/imag-diary/src/list.rs index 7294b463..ce6d7480 100644 --- a/bin/domain/imag-diary/src/list.rs +++ b/bin/domain/imag-diary/src/list.rs @@ -55,9 +55,7 @@ pub fn list(rt: &Runtime) { .map(IntoStoreId::into_storeid) .trace_unwrap_exit(1) .for_each(|id| { - let _ = rt - .report_touched(&id) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); writeln!(rt.stdout(), "{}", id).to_exit_code().unwrap_or_exit() }); diff --git a/bin/domain/imag-diary/src/view.rs b/bin/domain/imag-diary/src/view.rs index 5d28b412..dd1c4d66 100644 --- a/bin/domain/imag-diary/src/view.rs +++ b/bin/domain/imag-diary/src/view.rs @@ -42,9 +42,7 @@ pub fn view(rt: &Runtime) { })); let entries = entries.map(|e| { - let _ = rt - .report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(); e }); diff --git a/bin/domain/imag-habit/src/main.rs b/bin/domain/imag-habit/src/main.rs index 5c7f8a75..3a822ee3 100644 --- a/bin/domain/imag-habit/src/main.rs +++ b/bin/domain/imag-habit/src/main.rs @@ -155,7 +155,7 @@ fn create(rt: &Runtime) { debug!("Builder = {:?}", hb); let fle = hb.build(rt.store()).map_err_trace_exit_unwrap(1); - let _ = rt.report_touched(fle.get_location()).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(fle.get_location()).unwrap_or_exit(); } fn delete(rt: &Runtime) { @@ -441,9 +441,7 @@ fn list(rt: &Runtime) { let mut list = lister_fn(&e); { - let _ = rt - .report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(); } v.append(&mut list); @@ -520,9 +518,7 @@ fn show(rt: &Runtime) { let mut instances = instance_lister_fn(&e); { - let _ = rt - .report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(); } v.append(&mut instances); @@ -582,9 +578,7 @@ fn done(rt: &Runtime) { } { - let _ = rt - .report_touched(r.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(r.get_location()).unwrap_or_exit(); } } diff --git a/bin/domain/imag-log/src/main.rs b/bin/domain/imag-log/src/main.rs index 900f3e43..525eff7e 100644 --- a/bin/domain/imag-log/src/main.rs +++ b/bin/domain/imag-log/src/main.rs @@ -171,7 +171,7 @@ fn show(rt: &Runtime) { let _ = rt .report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + .unwrap_or_exit(); Ok(()) }) .collect::, ExitCode>>() diff --git a/bin/domain/imag-mail/src/main.rs b/bin/domain/imag-mail/src/main.rs index 35b62368..0a7da7f0 100644 --- a/bin/domain/imag-mail/src/main.rs +++ b/bin/domain/imag-mail/src/main.rs @@ -95,7 +95,7 @@ fn import_mail(rt: &Runtime) { .map_info_str("Ok") .map_err_trace_exit_unwrap(1); - let _ = rt.report_touched(mail.fle().get_location()).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(mail.fle().get_location()).unwrap_or_exit(); } fn list(rt: &Runtime) { @@ -147,7 +147,7 @@ fn list(rt: &Runtime) { to = to ).to_exit_code().unwrap_or_exit(); - let _ = rt.report_touched(m.fle().get_location()).map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(m.fle().get_location()).unwrap_or_exit(); } let _ = rt.store() diff --git a/bin/domain/imag-notes/src/main.rs b/bin/domain/imag-notes/src/main.rs index 8758cbdf..2d9c03b4 100644 --- a/bin/domain/imag-notes/src/main.rs +++ b/bin/domain/imag-notes/src/main.rs @@ -112,9 +112,7 @@ fn create(rt: &Runtime) { .map_err_trace_exit_unwrap(1); } - let _ = rt - .report_touched(note.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(note.get_location()).unwrap_or_exit(); } fn delete(rt: &Runtime) { @@ -136,9 +134,7 @@ fn edit(rt: &Runtime) { .map_warn_err_str("Editing failed") .map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(note.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(note.get_location()).unwrap_or_exit(); }) .unwrap_or_else(|| { error!("Cannot find note with name '{}'", name); @@ -170,9 +166,7 @@ fn list(rt: &Runtime) { .to_exit_code() .unwrap_or_exit(); - let _ = rt - .report_touched(note.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(note.get_location()).unwrap_or_exit(); }); } diff --git a/bin/domain/imag-timetrack/src/cont.rs b/bin/domain/imag-timetrack/src/cont.rs index 1e88dd62..60ab9553 100644 --- a/bin/domain/imag-timetrack/src/cont.rs +++ b/bin/domain/imag-timetrack/src/cont.rs @@ -87,8 +87,7 @@ pub fn cont(rt: &Runtime) -> i32 { .map(|_| 0) .map_err_trace(); - let _ = rt.report_touched(tracking.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(tracking.get_location()).unwrap_or_exit(); val }) diff --git a/bin/domain/imag-timetrack/src/day.rs b/bin/domain/imag-timetrack/src/day.rs index 2cff8fb1..6a099043 100644 --- a/bin/domain/imag-timetrack/src/day.rs +++ b/bin/domain/imag-timetrack/src/day.rs @@ -103,8 +103,7 @@ pub fn day(rt: &Runtime) -> i32 { let end = e.get_end_datetime()?; debug!(" -> end = {:?}", end); - let _ = rt.report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(); Ok((tag, start, end)) }) diff --git a/bin/domain/imag-timetrack/src/list.rs b/bin/domain/imag-timetrack/src/list.rs index 80019e8c..2e794121 100644 --- a/bin/domain/imag-timetrack/src/list.rs +++ b/bin/domain/imag-timetrack/src/list.rs @@ -162,8 +162,7 @@ pub fn list_impl(rt: &Runtime, .collect(); tab.add_row(Row::new(cells)); - let _ = rt.report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(); Ok(tab) }) diff --git a/bin/domain/imag-timetrack/src/month.rs b/bin/domain/imag-timetrack/src/month.rs index 8e9e7f60..f5bf99de 100644 --- a/bin/domain/imag-timetrack/src/month.rs +++ b/bin/domain/imag-timetrack/src/month.rs @@ -118,8 +118,7 @@ pub fn month(rt: &Runtime) -> i32 { let end = e.get_end_datetime()?; debug!(" -> end = {:?}", end); - let _ = rt.report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(1); Ok((tag, start, end)) }) diff --git a/bin/domain/imag-timetrack/src/start.rs b/bin/domain/imag-timetrack/src/start.rs index ff440233..39ddea4d 100644 --- a/bin/domain/imag-timetrack/src/start.rs +++ b/bin/domain/imag-timetrack/src/start.rs @@ -59,8 +59,7 @@ pub fn start(rt: &Runtime) -> i32 { 1 }, Ok(entry) => { - let _ = rt.report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); acc } diff --git a/bin/domain/imag-timetrack/src/stop.rs b/bin/domain/imag-timetrack/src/stop.rs index 2eee55f5..2fc27bea 100644 --- a/bin/domain/imag-timetrack/src/stop.rs +++ b/bin/domain/imag-timetrack/src/stop.rs @@ -98,8 +98,7 @@ pub fn stop(rt: &Runtime) -> i32 { } Ok(_) => { format!("Setting end time worked: {:?}", elem); - let _ = rt.report_touched(elem.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(elem.get_location()).unwrap_or_exit(); acc } } diff --git a/bin/domain/imag-timetrack/src/track.rs b/bin/domain/imag-timetrack/src/track.rs index c9171e10..f89047a0 100644 --- a/bin/domain/imag-timetrack/src/track.rs +++ b/bin/domain/imag-timetrack/src/track.rs @@ -87,8 +87,7 @@ pub fn track(rt: &Runtime) -> i32 { 1 }, Ok(entry) => { - let _ = rt.report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); acc } }) diff --git a/bin/domain/imag-timetrack/src/week.rs b/bin/domain/imag-timetrack/src/week.rs index e003d2f9..5c384036 100644 --- a/bin/domain/imag-timetrack/src/week.rs +++ b/bin/domain/imag-timetrack/src/week.rs @@ -116,8 +116,7 @@ pub fn week(rt: &Runtime) -> i32 { let end = e.get_end_datetime()?; debug!(" -> end = {:?}", end); - let _ = rt.report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(); Ok((tag, start, end)) }) diff --git a/bin/domain/imag-timetrack/src/year.rs b/bin/domain/imag-timetrack/src/year.rs index 4bd48d20..16d30050 100644 --- a/bin/domain/imag-timetrack/src/year.rs +++ b/bin/domain/imag-timetrack/src/year.rs @@ -116,8 +116,7 @@ pub fn year(rt: &Runtime) -> i32 { let end = e.get_end_datetime()?; debug!(" -> end = {:?}", end); - let _ = rt.report_touched(e.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(e.get_location()).unwrap_or_exit(); Ok((tag, start, end)) }) diff --git a/bin/domain/imag-wiki/src/main.rs b/bin/domain/imag-wiki/src/main.rs index 179b3005..a32960f6 100644 --- a/bin/domain/imag-wiki/src/main.rs +++ b/bin/domain/imag-wiki/src/main.rs @@ -181,9 +181,7 @@ fn create(rt: &Runtime, wiki_name: &str) { writeln!(lock, "{}", id).to_exit_code().unwrap_or_exit() } - let _ = rt - .report_touched(&id) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(&id).unwrap_or_exit(); } fn create_wiki(rt: &Runtime) { @@ -191,9 +189,7 @@ fn create_wiki(rt: &Runtime) { let wiki_name = String::from(scmd.value_of("create-wiki-name").unwrap()); // safe by clap let (_, index) = rt.store().create_wiki(&wiki_name).map_err_trace_exit_unwrap(1); - let _ = rt - .report_touched(index.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(index.get_location()).unwrap_or_exit(); } fn show(rt: &Runtime, wiki_name: &str) { @@ -251,9 +247,7 @@ fn show(rt: &Runtime, wiki_name: &str) { .to_exit_code() .unwrap_or_exit(); - let _ = rt - .report_touched(entry.get_location()) - .map_err_trace_exit_unwrap(1); + let _ = rt.report_touched(entry.get_location()).unwrap_or_exit(); } } diff --git a/lib/core/libimagrt/src/runtime.rs b/lib/core/libimagrt/src/runtime.rs index 5fb367dc..2466fad4 100644 --- a/lib/core/libimagrt/src/runtime.rs +++ b/lib/core/libimagrt/src/runtime.rs @@ -25,6 +25,7 @@ use std::io::Stdin; use std::sync::Arc; use std::io::StdoutLock; use std::borrow::Borrow; +use std::result::Result as RResult; pub use clap::App; use clap::AppSettings; @@ -41,8 +42,10 @@ use configuration::{fetch_config, override_config, InternalConfiguration}; use logger::ImagLogger; use io::OutputProxy; +use libimagerror::exit::ExitCode; use libimagerror::errors::ErrorMsg as EM; use libimagerror::trace::*; +use libimagerror::io::ToExitCode; use libimagstore::store::Store; use libimagstore::storeid::StoreId; use libimagstore::file_abstraction::InMemoryFileAbstraction; @@ -573,14 +576,14 @@ impl<'a> Runtime<'a> { .map_err(Error::from) } - pub fn report_touched(&self, id: &StoreId) -> Result<()> { + pub fn report_touched(&self, id: &StoreId) -> RResult<(), ExitCode> { let out = ::std::io::stdout(); let mut lock = out.lock(); self.report_touched_id(id, &mut lock) } - pub fn report_all_touched(&self, ids: I) -> Result<()> + pub fn report_all_touched(&self, ids: I) -> RResult<(), ExitCode> where ID: Borrow + Sized, I: Iterator { @@ -595,15 +598,15 @@ impl<'a> Runtime<'a> { } #[inline] - fn report_touched_id(&self, id: &StoreId, output: &mut StdoutLock) -> Result<()> { + fn report_touched_id(&self, id: &StoreId, output: &mut StdoutLock) -> RResult<(), ExitCode> { use std::io::Write; if self.output_is_pipe() && !self.ignore_ids { trace!("Reporting: {} to {:?}", id, output); - writeln!(output, "{}", id)?; + writeln!(output, "{}", id).to_exit_code() + } else { + Ok(()) } - - Ok(()) } }