summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-diary/src/create.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/domain/imag-diary/src/create.rs')
-rw-r--r--bin/domain/imag-diary/src/create.rs26
1 files changed, 13 insertions, 13 deletions
diff --git a/bin/domain/imag-diary/src/create.rs b/bin/domain/imag-diary/src/create.rs
index 43b25d6a..8dccbee8 100644
--- a/bin/domain/imag-diary/src/create.rs
+++ b/bin/domain/imag-diary/src/create.rs
@@ -21,10 +21,10 @@ use clap::ArgMatches;
use chrono::NaiveDateTime;
use chrono::Local;
use chrono::Timelike;
-use failure::Error;
-use failure::ResultExt;
-use failure::err_msg;
-use failure::Fallible as Result;
+use anyhow::Error;
+use anyhow::Context;
+
+use anyhow::Result;
use option_inspect::*;
use libimagdiary::diary::Diary;
@@ -39,7 +39,7 @@ use crate::util::Timed;
pub fn create(rt: &Runtime) -> Result<()> {
let diaryname = get_diary_name(rt)
- .ok_or_else(|| err_msg("No diary selected. Use either the configuration file or the commandline option"))?;
+ .ok_or_else(|| anyhow!("No diary selected. Use either the configuration file or the commandline option"))?;
let mut entry = create_entry(rt.store(), &diaryname, rt)?;
rt.report_touched(entry.get_location())?;
@@ -50,7 +50,7 @@ pub fn create(rt: &Runtime) -> Result<()> {
Ok(())
} else {
debug!("Editing new diary entry");
- entry.edit_content(rt).context(err_msg("Diary edit error")).map_err(Error::from)
+ entry.edit_content(rt).context(anyhow!("Diary edit error")).map_err(Error::from)
}
}
@@ -67,7 +67,7 @@ fn create_entry<'a>(diary: &'a Store, diaryname: &str, rt: &Runtime) -> Result<F
if let Some(timed) = timed {
let time = create_id_from_clispec(&create, timed)?;
diary.new_entry_at(&diaryname, &time)
- .context(err_msg("Store write error"))
+ .context(anyhow!("Store write error"))
.map_err(Error::from)
} else {
debug!("Creating non-timed entry");
@@ -107,7 +107,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> Result<Naiv
.map(|s| {
FromStr::from_str(s)
.map_err(Error::from)
- .context(format_err!("Could not parse minute: '{}'", s))
+ .context(anyhow!("Could not parse minute: '{}'", s))
.map_err(Error::from)
})
.transpose()?
@@ -115,7 +115,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> Result<Naiv
ndt.with_minute(min)
.ok_or_else(|| {
- format_err!("Cannot set {} as minute, would yield invalid time!", min)
+ anyhow!("Cannot set {} as minute, would yield invalid time!", min)
})
.map(|ndt| ndt.with_second(0).unwrap()) // safe because second = 0 is safe
},
@@ -127,7 +127,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> Result<Naiv
.map(|s| {
FromStr::from_str(s)
.map_err(Error::from)
- .context(format_err!("Could not parse minute: '{}'", s))
+ .context(anyhow!("Could not parse minute: '{}'", s))
.map_err(Error::from)
})
.transpose()?
@@ -139,7 +139,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> Result<Naiv
.map(|s| {
FromStr::from_str(s)
.map_err(Error::from)
- .context(format_err!("Could not parse second: '{}'", s))
+ .context(anyhow!("Could not parse second: '{}'", s))
.map_err(Error::from)
})
.transpose()?
@@ -147,11 +147,11 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> Result<Naiv
ndt.with_minute(min)
.ok_or_else(|| {
- format_err!("Cannot set {} as minute, would yield invalid time!", min)
+ anyhow!("Cannot set {} as minute, would yield invalid time!", min)
})?
.with_second(sec)
.ok_or_else(|| {
- format_err!("Cannot set {} as second, would yield invalid time!", sec)
+ anyhow!("Cannot set {} as second, would yield invalid time!", sec)
})
},
}