summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-contact/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/domain/imag-contact/src/lib.rs')
-rw-r--r--bin/domain/imag-contact/src/lib.rs34
1 files changed, 17 insertions, 17 deletions
diff --git a/bin/domain/imag-contact/src/lib.rs b/bin/domain/imag-contact/src/lib.rs
index dcfaeb26..13f17e0f 100644
--- a/bin/domain/imag-contact/src/lib.rs
+++ b/bin/domain/imag-contact/src/lib.rs
@@ -43,7 +43,7 @@ extern crate handlebars;
extern crate walkdir;
extern crate uuid;
extern crate serde_json;
-#[macro_use] extern crate failure;
+#[macro_use] extern crate anyhow;
extern crate resiter;
extern crate libimagcontact;
@@ -64,9 +64,9 @@ use toml_query::read::TomlValueReadExt;
use toml_query::read::TomlValueReadTypeExt;
use toml_query::read::Partial;
use walkdir::WalkDir;
-use failure::Error;
-use failure::err_msg;
-use failure::Fallible as Result;
+use anyhow::Error;
+
+use anyhow::Result;
use resiter::AndThen;
use resiter::IterInnerOkOrElse;
use resiter::Map;
@@ -97,7 +97,7 @@ use crate::edit::edit;
pub enum ImagContact {}
impl ImagApplication for ImagContact {
fn run(rt: Runtime) -> Result<()> {
- match rt.cli().subcommand_name().ok_or_else(|| err_msg("No subcommand called"))? {
+ match rt.cli().subcommand_name().ok_or_else(|| anyhow!("No subcommand called"))? {
"list" => list(&rt),
"import" => import(&rt),
"show" => show(&rt),
@@ -109,7 +109,7 @@ impl ImagApplication for ImagContact {
if rt.handle_unknown_subcommand("imag-contact", other, rt.cli())?.success() {
Ok(())
} else {
- Err(err_msg("Failed to handle unknown subcommand"))
+ Err(anyhow!("Failed to handle unknown subcommand"))
}
},
}
@@ -141,7 +141,7 @@ fn list(rt: &Runtime) -> Result<()> {
.store()
.all_contacts()?
.into_get_iter()
- .map_inner_ok_or_else(|| err_msg("Did not find one entry"))
+ .map_inner_ok_or_else(|| anyhow!("Did not find one entry"))
.and_then_ok(|fle| {
rt.report_touched(fle.get_location())?;
Ok(fle)
@@ -177,14 +177,14 @@ fn import(rt: &Runtime) -> Result<()> {
let collection_name = rt.cli().value_of("contact-ref-collection-name").unwrap(); // default by clap
let ref_config = rt.config()
- .ok_or_else(|| format_err!("No configuration, cannot continue!"))?
+ .ok_or_else(|| anyhow!("No configuration, cannot continue!"))?
.read_partial::<libimagentryref::reference::Config>()?
- .ok_or_else(|| format_err!("Configuration missing: {}", libimagentryref::reference::Config::LOCATION))?;
+ .ok_or_else(|| anyhow!("Configuration missing: {}", libimagentryref::reference::Config::LOCATION))?;
// TODO: Refactor the above to libimagutil or libimagrt?
if !path.exists() {
- return Err(format_err!("Path does not exist: {}", path.display()))
+ return Err(anyhow!("Path does not exist: {}", path.display()))
}
if path.is_file() {
@@ -216,7 +216,7 @@ fn import(rt: &Runtime) -> Result<()> {
.collect::<Result<Vec<_>>>()
.map(|_| ())
} else {
- Err(err_msg("Path is neither directory nor file"))
+ Err(anyhow!("Path is neither directory nor file"))
}
}
@@ -253,7 +253,7 @@ fn show(rt: &Runtime) -> Result<()> {
.map(PathBuf::from)
.map(StoreId::new)
.into_get_iter(rt.store())
- .map_inner_ok_or_else(|| err_msg("Did not find one entry"));
+ .map_inner_ok_or_else(|| anyhow!("Did not find one entry"));
show_contacts(rt, &show_format, iter)
} else {
@@ -268,11 +268,11 @@ fn show(rt: &Runtime) -> Result<()> {
}
} else {
let iter = rt.ids::<crate::ui::PathProvider>()?
- .ok_or_else(|| err_msg("No ids supplied"))?
+ .ok_or_else(|| anyhow!("No ids supplied"))?
.into_iter()
.map(Ok)
.into_get_iter(rt.store())
- .map_inner_ok_or_else(|| err_msg("Did not find one entry"));
+ .map_inner_ok_or_else(|| anyhow!("Did not find one entry"));
show_contacts(rt, &show_format, iter)
}
@@ -294,7 +294,7 @@ fn find(rt: &Runtime) -> Result<()> {
.store()
.all_contacts()?
.into_get_iter()
- .map_inner_ok_or_else(|| err_msg("Did not find one entry"))
+ .map_inner_ok_or_else(|| anyhow!("Did not find one entry"))
.and_then_ok(|entry| {
let card = entry.deser()?;
@@ -384,9 +384,9 @@ fn get_contact_print_format(config_value_path: &'static str, rt: &Runtime, scmd:
let fmt = match scmd.value_of("format").map(String::from) {
Some(s) => Ok(s),
None => rt.config()
- .ok_or_else(|| err_msg("No configuration file"))?
+ .ok_or_else(|| anyhow!("No configuration file"))?
.read_string(config_value_path)?
- .ok_or_else(|| err_msg("Configuration 'contact.list_format' does not exist")),
+ .ok_or_else(|| anyhow!("Configuration 'contact.list_format' does not exist")),
}?;
let mut hb = Handlebars::new();