diff --git a/imag-diary/src/create.rs b/imag-diary/src/create.rs index 66818527..c715cfaf 100644 --- a/imag-diary/src/create.rs +++ b/imag-diary/src/create.rs @@ -9,15 +9,13 @@ use libimagrt::runtime::Runtime; use libimagerror::trace::trace_error; use libimagdiary::entry::Entry; use libimagdiary::result::Result; +use libimagutil::warn_exit::warn_exit; use util::get_diary_name; pub fn create(rt: &Runtime) { let diaryname = get_diary_name(rt) - .unwrap_or_else(|| { - warn!("No diary selected. Use either the configuration file or the commandline option"); - exit(1) - }); + .unwrap_or_else( || warn_exit("No diary selected. Use either the configuration file or the commandline option", 1)); let prevent_edit = rt.cli().subcommand_matches("create").unwrap().is_present("no-edit"); @@ -78,10 +76,7 @@ pub fn create(rt: &Runtime) { exit(1); }, - None => { - warn!("Unexpected error, cannot continue"); - exit(1); - }, + None => warn_exit("Unexpected error, cannot continue", 1) }; diary.new_entry_by_id(id) diff --git a/imag-diary/src/delete.rs b/imag-diary/src/delete.rs index d5fd75e7..aec5a8eb 100644 --- a/imag-diary/src/delete.rs +++ b/imag-diary/src/delete.rs @@ -1,4 +1,3 @@ -use std::process::exit; use chrono::naive::datetime::NaiveDateTime; use libimagdiary::diary::Diary; @@ -7,16 +6,15 @@ use libimagrt::runtime::Runtime; use libimagerror::trace::trace_error_exit; use libimagtimeui::datetime::DateTime; use libimagtimeui::parse::Parse; +use libimagutil::warn_exit::warn_exit; use util::get_diary_name; pub fn delete(rt: &Runtime) { use libimaginteraction::ask::ask_bool; - let diaryname = get_diary_name(rt).unwrap_or_else(|| { - warn!("No diary selected. Use either the configuration file or the commandline option"); - exit(1); - }); + let diaryname = get_diary_name(rt) + .unwrap_or_else(|| warn_exit("No diary selected. Use either the configuration file or the commandline option", 1)); let diary = Diary::open(rt.store(), &diaryname[..]); debug!("Diary opened: {:?}", diary); @@ -39,10 +37,7 @@ pub fn delete(rt: &Runtime) { Some(Ok(e)) => e, Some(Err(e)) => trace_error_exit(&e, 1), - None => { - warn!("No entry"); - exit(1); - }, + None => warn_exit("No entry", 1) }; if !ask_bool(&format!("Deleting {:?}", to_del.get_location())[..], Some(true)) { diff --git a/imag-diary/src/edit.rs b/imag-diary/src/edit.rs index 7b79aa26..88dd5eef 100644 --- a/imag-diary/src/edit.rs +++ b/imag-diary/src/edit.rs @@ -1,4 +1,3 @@ -use std::process::exit; use chrono::naive::datetime::NaiveDateTime; use libimagdiary::diary::Diary; @@ -11,15 +10,12 @@ use libimagerror::trace::trace_error; use libimagerror::into::IntoError; use libimagtimeui::datetime::DateTime; use libimagtimeui::parse::Parse; +use libimagutil::warn_exit::warn_exit; use util::get_diary_name; pub fn edit(rt: &Runtime) { - let diaryname = get_diary_name(rt).unwrap_or_else(|| { - warn!("No diary name"); - exit(1); - }); - + let diaryname = get_diary_name(rt).unwrap_or_else(|| warn_exit("No diary name", 1)); let diary = Diary::open(rt.store(), &diaryname[..]); let datetime : Option = rt diff --git a/imag-diary/src/list.rs b/imag-diary/src/list.rs index 757cf3a1..72d2d5ab 100644 --- a/imag-diary/src/list.rs +++ b/imag-diary/src/list.rs @@ -1,5 +1,3 @@ -use std::process::exit; - use libimagdiary::diary::Diary; use libimagdiary::error::DiaryErrorKind as DEK; use libimagdiary::error::MapErrInto; @@ -8,14 +6,13 @@ use libimagentrylist::lister::Lister; use libimagrt::runtime::Runtime; use libimagstore::store::Entry; use libimagerror::trace::trace_error; +use libimagutil::warn_exit::warn_exit; use util::get_diary_name; pub fn list(rt: &Runtime) { - let diaryname = get_diary_name(rt).unwrap_or_else(|| { - warn!("No diary selected. Use either the configuration file or the commandline option"); - exit(1); - }); + let diaryname = get_diary_name(rt) + .unwrap_or_else(|| warn_exit("No diary selected. Use either the configuration file or the commandline option", 1)); fn entry_to_location_listing_string(e: &Entry) -> String { e.get_location().clone() diff --git a/imag-diary/src/view.rs b/imag-diary/src/view.rs index c214eafe..742bc262 100644 --- a/imag-diary/src/view.rs +++ b/imag-diary/src/view.rs @@ -1,19 +1,14 @@ -use std::process::exit; - use libimagdiary::diary::Diary; use libimagentryview::viewer::Viewer; use libimagentryview::builtin::plain::PlainViewer; use libimagrt::runtime::Runtime; use libimagerror::trace::trace_error; +use libimagutil::warn_exit::warn_exit; use util::get_diary_name; pub fn view(rt: &Runtime) { - let diaryname = get_diary_name(rt).unwrap_or_else(|| { - warn!("No diary name"); - exit(1); - }); - + let diaryname = get_diary_name(rt).unwrap_or_else(|| warn_exit("No diary name", 1)); let diary = Diary::open(rt.store(), &diaryname[..]); let show_header = rt.cli().subcommand_matches("view").unwrap().is_present("show-header");