summaryrefslogtreecommitdiffstats
path: root/bin/core/imag-annotate/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/core/imag-annotate/src/lib.rs')
-rw-r--r--bin/core/imag-annotate/src/lib.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/bin/core/imag-annotate/src/lib.rs b/bin/core/imag-annotate/src/lib.rs
index 42cbea67..df0a9374 100644
--- a/bin/core/imag-annotate/src/lib.rs
+++ b/bin/core/imag-annotate/src/lib.rs
@@ -38,7 +38,7 @@ extern crate clap;
#[macro_use]
extern crate log;
#[macro_use]
-extern crate failure;
+extern crate anyhow;
extern crate toml_query;
extern crate resiter;
@@ -52,10 +52,10 @@ extern crate libimagentrylink;
use std::io::Write;
-use failure::Error;
-use failure::Fallible as Result;
-use failure::ResultExt;
-use failure::err_msg;
+use anyhow::Error;
+use anyhow::Result;
+use anyhow::Context;
+
use resiter::IterInnerOkOrElse;
use resiter::AndThen;
use resiter::Map;
@@ -65,7 +65,7 @@ use clap::App;
use libimagentryannotation::annotateable::*;
use libimagentryannotation::annotation_fetcher::*;
use libimagentryedit::edit::*;
-use libimagerror::errors::ErrorMsg as EM;
+use libimagerror::errors::Error as EM;
use libimagrt::runtime::Runtime;
use libimagrt::application::ImagApplication;
use libimagstore::store::FileLockEntry;
@@ -78,7 +78,7 @@ mod ui;
pub enum ImagAnnotate {}
impl ImagApplication for ImagAnnotate {
fn run(rt: Runtime) -> Result<()> {
- match rt.cli().subcommand_name().ok_or_else(|| err_msg("No command called"))? {
+ match rt.cli().subcommand_name().ok_or_else(|| anyhow!("No command called"))? {
"add" => add(&rt),
"remove" => remove(&rt),
"list" => list(&rt),
@@ -87,7 +87,7 @@ impl ImagApplication for ImagAnnotate {
if rt.handle_unknown_subcommand("imag-annotation", other, rt.cli())?.success() {
Ok(())
} else {
- Err(err_msg("Failed to handle unknown subcommand"))
+ Err(anyhow!("Failed to handle unknown subcommand"))
}
},
}
@@ -115,7 +115,7 @@ fn add(rt: &Runtime) -> Result<()> {
let mut ids = rt
.ids::<crate::ui::PathProvider>()
.context("No StoreId supplied")?
- .ok_or_else(|| err_msg("No ids supplied"))?
+ .ok_or_else(|| anyhow!("No ids supplied"))?
.into_iter();
if let Some(first) = ids.next() {
@@ -128,7 +128,7 @@ fn add(rt: &Runtime) -> Result<()> {
rt.report_touched(&first)?; // report first one first
ids.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"))
.and_then_ok(|mut entry| entry.add_link(&mut annotation).map(|_| entry))
.map_report_touched(&rt)
.map_ok(|_| ())
@@ -141,7 +141,7 @@ fn add(rt: &Runtime) -> Result<()> {
{
writeln!(rt.stdout(), "Name of the annotation: {}", annotation_id)?;
} else {
- Err(format_err!("Unnamed annotation: {:?}", annotation.get_location()))
+ Err(anyhow!("Unnamed annotation: {:?}", annotation.get_location()))
.context("This is most likely a BUG, please report!")?;
}
}
@@ -161,7 +161,7 @@ fn remove(rt: &Runtime) -> Result<()> {
rt.ids::<crate::ui::PathProvider>()
.context("No ids supplied")?
- .ok_or_else(|| err_msg("No ids supplied"))?
+ .ok_or_else(|| anyhow!("No ids supplied"))?
.into_iter()
.map(|id| {
let mut entry = rt.store()
@@ -195,7 +195,7 @@ fn list(rt: &Runtime) -> Result<()> {
let ids = rt
.ids::<crate::ui::PathProvider>()
.context("No ids supplied")?
- .ok_or_else(|| err_msg("No ids supplied"))?;
+ .ok_or_else(|| anyhow!("No ids supplied"))?;
if ids.is_empty() {
ids.into_iter()
@@ -206,7 +206,7 @@ fn list(rt: &Runtime) -> Result<()> {
.ok_or_else(|| EM::EntryNotFound(lds))?
.annotations()?
.into_get_iter(rt.store())
- .map(|el| el.and_then(|o| o.ok_or_else(|| format_err!("Cannot find entry"))))
+ .map(|el| el.and_then(|o| o.ok_or_else(|| anyhow!("Cannot find entry"))))
.enumerate()
.map(|(i, entry)| entry.and_then(|e| list_annotation(&rt, i, &e, with_text).map(|_| e)))
.map_report_touched(&rt)
@@ -220,7 +220,7 @@ fn list(rt: &Runtime) -> Result<()> {
rt.store()
.all_annotations()?
.into_get_iter()
- .map(|el| el.and_then(|opt| opt.ok_or_else(|| format_err!("Cannot find entry"))))
+ .map(|el| el.and_then(|opt| opt.ok_or_else(|| anyhow!("Cannot find entry"))))
.enumerate()
.map(|(i, entry)| entry.and_then(|e| list_annotation(&rt, i, &e, with_text).map(|_| e)))
.map_report_touched(&rt)