diff options
Diffstat (limited to 'bin/core')
60 files changed, 244 insertions, 244 deletions
diff --git a/bin/core/imag-annotate/Cargo.toml b/bin/core/imag-annotate/Cargo.toml index 5c5b89da..34e0ef4f 100644 --- a/bin/core/imag-annotate/Cargo.toml +++ b/bin/core/imag-annotate/Cargo.toml @@ -24,7 +24,7 @@ log = "0.4.6" url = "2" toml = "0.5.1" toml-query = "0.9.2" -failure = "0.1.5" +anyhow = "1" resiter = "0.4.0" libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" } 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) diff --git a/bin/core/imag-annotate/src/ui.rs b/bin/core/imag-annotate/src/ui.rs index e47a1505..a7bd3364 100644 --- a/bin/core/imag-annotate/src/ui.rs +++ b/bin/core/imag-annotate/src/ui.rs @@ -25,7 +25,7 @@ use libimagstore::storeid::StoreId; use libimagstore::storeid::IntoStoreId; use libimagrt::runtime::IdPathProvider; -use failure::Fallible as Result; +use anyhow::Result; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app @@ -114,7 +114,7 @@ impl IdPathProvider for PathProvider { ("remove", Some(subm)) => get_id_paths(subm), ("list", Some(subm)) => get_id_paths(subm), (other, _) => { - Err(format_err!("Not a known command: {}", other)) + Err(anyhow!("Not a known command: {}", other)) } } } diff --git a/bin/core/imag-category/Cargo.toml b/bin/core/imag-category/Cargo.toml index 5fb0c0a0..6f75f487 100644 --- a/bin/core/imag-category/Cargo.toml +++ b/bin/core/imag-category/Cargo.toml @@ -23,7 +23,7 @@ maintenance = { status = "actively-developed" } log = "0.4.6" toml = "0.5.1" toml-query = "0.9.2" -failure = "0.1.5" +anyhow = "1" resiter = "0.4.0" libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" } diff --git a/bin/core/imag-category/src/lib.rs b/bin/core/imag-category/src/lib.rs index c1c2ed73..d6eb18ef 100644 --- a/bin/core/imag-category/src/lib.rs +++ b/bin/core/imag-category/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 resiter; extern crate libimagentrycategory; @@ -47,7 +47,7 @@ extern crate libimagrt; extern crate libimagstore; extern crate libimaginteraction; -use failure::Fallible as Result; +use anyhow::Result; use resiter::Map; use clap::App; @@ -59,8 +59,8 @@ mod ui; use std::io::Write; -use failure::err_msg; -use failure::Error; + +use anyhow::Error; use resiter::AndThen; use resiter::IterInnerOkOrElse; @@ -76,7 +76,7 @@ use libimagentrycategory::category::Category; pub enum ImagCategory {} impl ImagApplication for ImagCategory { 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"))? { "set" => set(&rt), "get" => get(&rt), "list-category" => list_category(&rt), @@ -88,7 +88,7 @@ impl ImagApplication for ImagCategory { if rt.handle_unknown_subcommand("imag-category", other, rt.cli())?.success() { Ok(()) } else { - Err(err_msg("Failed to handle unknown subcommand")) + Err(anyhow!("Failed to handle unknown subcommand")) } }, } @@ -116,11 +116,11 @@ fn set(rt: &Runtime) -> Result<()> { let scmd = rt.cli().subcommand_matches("set").unwrap(); // safed by main() let name = scmd.value_of("set-name").map(String::from).unwrap(); // safed by clap 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")) .and_then_ok(|mut e| e.set_category_checked(rt.store(), &name).map(|_| e)) .map_report_touched(&rt) .map_ok(|_| ()) @@ -131,11 +131,11 @@ fn get(rt: &Runtime) -> Result<()> { let out = rt.stdout(); let mut outlock = out.lock(); 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")) .map_report_touched(&rt) .and_then_ok(|e| e.get_category()) .and_then_ok(|n| writeln!(outlock, "{}", n).map_err(Error::from)) @@ -156,7 +156,7 @@ fn list_category(rt: &Runtime) -> Result<()> { .map(|entry| writeln!(outlock, "{}", entry?.get_location()).map_err(Error::from)) .collect() } else { - Err(format_err!("No category named '{}'", name)) + Err(anyhow!("No category named '{}'", name)) } } @@ -175,7 +175,7 @@ fn delete_category(rt: &Runtime) -> Result<()> { let name = scmd.value_of("delete-category-name").map(String::from).unwrap(); // safed by clap let ques = format!("Do you really want to delete category '{}' and remove links to all categorized enties?", name); - let mut input = rt.stdin().ok_or_else(|| err_msg("No input stream. Cannot ask for permission"))?; + let mut input = rt.stdin().ok_or_else(|| anyhow!("No input stream. Cannot ask for permission"))?; let mut output = rt.stdout(); let answer = ask_bool(&ques, Some(false), &mut input, &mut output)?; diff --git a/bin/core/imag-category/src/ui.rs b/bin/core/imag-category/src/ui.rs index 6f80539c..a5810c80 100644 --- a/bin/core/imag-category/src/ui.rs +++ b/bin/core/imag-category/src/ui.rs @@ -20,7 +20,7 @@ use std::path::PathBuf; use clap::{Arg, ArgMatches, App, SubCommand}; -use failure::Fallible as Result; +use anyhow::Result; use libimagstore::storeid::StoreId; use libimagstore::storeid::IntoStoreId; @@ -105,7 +105,7 @@ pub struct PathProvider; impl IdPathProvider for PathProvider { fn get_ids(matches: &ArgMatches) -> Result<Option<Vec<StoreId>>> { fn no_ids_error() -> Result<Option<Vec<StoreId>>> { - Err(format_err!("Command does not get IDs as input")) + Err(anyhow!("Command does not get IDs as input")) } fn get_id_paths(field: &str, subm: &ArgMatches) -> Result<Option<Vec<StoreId>>> { @@ -125,7 +125,7 @@ impl IdPathProvider for PathProvider { ("list-category", _) => no_ids_error(), ("set", Some(subm)) => get_id_paths("set-ids", subm), ("get", Some(subm)) => get_id_paths("get-ids", subm), - (other, _) => Err(format_err!("Not a known command: {}", other)), + (other, _) => Err(anyhow!("Not a known command: {}", other)), } } } diff --git a/bin/core/imag-create/Cargo.toml b/bin/core/imag-create/Cargo.toml index fca9dedc..e4ee82ea 100644 --- a/bin/core/imag-create/Cargo.toml +++ b/bin/core/imag-create/Cargo.toml @@ -16,7 +16,7 @@ homepage = "http://imag-pim.org" [dependencies] log = "0.4" -failure = "0.1" +anyhow = "1" libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" } libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" } diff --git a/bin/core/imag-create/src/lib.rs b/bin/core/imag-create/src/lib.rs index 03004ea4..674f1ef9 100644 --- a/bin/core/imag-create/src/lib.rs +++ b/bin/core/imag-create/src/lib.rs @@ -35,14 +35,14 @@ )] extern crate clap; -extern crate failure; +#[macro_use] extern crate anyhow; extern crate libimagerror; extern crate libimagrt; extern crate libimagstore; -use failure::Fallible as Result; -use failure::err_msg; +use anyhow::Result; + use clap::App; use libimagrt::runtime::Runtime; @@ -61,7 +61,7 @@ impl ImagApplication for ImagCreate { let force = rt.cli().is_present("force"); let ids = rt.ids::<crate::ui::PathProvider>()? - .ok_or_else(|| err_msg("No ids supplied"))? + .ok_or_else(|| anyhow!("No ids supplied"))? .into_iter() .map(Ok); diff --git a/bin/core/imag-create/src/ui.rs b/bin/core/imag-create/src/ui.rs index b832f17d..8e5cad01 100644 --- a/bin/core/imag-create/src/ui.rs +++ b/bin/core/imag-create/src/ui.rs @@ -20,7 +20,7 @@ use std::path::PathBuf; use clap::{Arg, ArgMatches, App}; -use failure::Fallible as Result; +use anyhow::Result; use libimagstore::storeid::StoreId; use libimagstore::storeid::IntoStoreId; diff --git a/bin/core/imag-diagnostics/Cargo.toml b/bin/core/imag-diagnostics/Cargo.toml index 557e3f7d..4637006e 100644 --- a/bin/core/imag-diagnostics/Cargo.toml +++ b/bin/core/imag-diagnostics/Cargo.toml @@ -18,7 +18,7 @@ log = "0.4.6" toml = "0.5.1" toml-query = "0.9.2" indicatif = "0.14.0" -failure = "0.1.5" +anyhow = "1" resiter = "0.4.0" libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" } diff --git a/bin/core/imag-diagnostics/src/lib.rs b/bin/core/imag-diagnostics/src/lib.rs index 427abc67..ac7963f9 100644 --- a/bin/core/imag-diagnostics/src/lib.rs +++ b/bin/core/imag-diagnostics/src/lib.rs @@ -38,7 +38,7 @@ extern crate clap; extern crate toml; extern crate toml_query; extern crate indicatif; -extern crate failure; +#[macro_use] extern crate anyhow; extern crate resiter; #[macro_use] extern crate log; @@ -58,8 +58,8 @@ use libimagentrylink::linkable::Linkable; use toml::Value; use toml_query::read::TomlValueReadExt; use indicatif::{ProgressIterator, ProgressBar, ProgressStyle}; -use failure::Fallible as Result; -use failure::err_msg; +use anyhow::Result; + use clap::App; use resiter::AndThen; use resiter::IterInnerOkOrElse; @@ -132,7 +132,7 @@ impl ImagApplication for ImagDiagnostics { let diags = rt.store() .entries()? .into_get_iter() - .map_inner_ok_or_else(|| err_msg("Unable to get entry")) + .map_inner_ok_or_else(|| anyhow!("Unable to get entry")) .progress_with(progressbar) .and_then_ok(|e| { let diag = Diagnostic::for_entry(&e); @@ -254,11 +254,11 @@ impl ImagApplication for ImagDiagnostics { } fn get_config(rt: &Runtime, s: &'static str) -> Result<Option<String>> { - let cfg = rt.config().ok_or_else(|| err_msg("No configuration"))?; + let cfg = rt.config().ok_or_else(|| anyhow!("No configuration"))?; match cfg.read(s)? { Some(&Value::String(ref s)) => Ok(Some(s.to_owned())), - Some(_) => Err(err_msg("Config type wrong: 'rt.progressbar_style' should be a string")), + Some(_) => Err(anyhow!("Config type wrong: 'rt.progressbar_style' should be a string")), None => Ok(None), } } diff --git a/bin/core/imag-edit/Cargo.toml b/bin/core/imag-edit/Cargo.toml index 2ec48cfc..5e7a0df7 100644 --- a/bin/core/imag-edit/Cargo.toml +++ b/bin/core/imag-edit/Cargo.toml @@ -24,7 +24,7 @@ log = "0.4.6" version = "3.0.0" toml = "0.5.1" toml-query = "0.9.2" -failure = "0.1.5" +anyhow = "1" resiter = "0.4.0" libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" } diff --git a/bin/core/imag-edit/src/lib.rs b/bin/core/imag-edit/src/lib.rs index d86e7b37..29239e38 100644 --- a/bin/core/imag-edit/src/lib.rs +++ b/bin/core/imag-edit/src/lib.rs @@ -36,7 +36,7 @@ extern crate clap; #[macro_use] extern crate log; -extern crate failure; +#[macro_use] extern crate anyhow; extern crate resiter; extern crate libimagentryedit; @@ -52,8 +52,8 @@ use libimagrt::application::ImagApplication; use libimagrt::iter::ReportTouchedResultEntry; use libimagstore::iter::get::StoreIdGetIteratorExtension; -use failure::Fallible as Result; -use failure::err_msg; +use anyhow::Result; + use resiter::AndThen; use resiter::IterInnerOkOrElse; use clap::App; @@ -71,11 +71,11 @@ impl ImagApplication for ImagEdit { let edit_header_only = rt.cli().is_present("edit-header-only"); 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")) .inspect(|e| debug!("Editing = {:?}", e)) .map_report_touched(&rt) .and_then_ok(|mut entry| { diff --git a/bin/core/imag-edit/src/ui.rs b/bin/core/imag-edit/src/ui.rs index f13b8fc6..5a195a22 100644 --- a/bin/core/imag-edit/src/ui.rs +++ b/bin/core/imag-edit/src/ui.rs @@ -20,7 +20,7 @@ use std::path::PathBuf; use clap::{Arg, ArgMatches, App}; -use failure::Fallible as Result; +use anyhow::Result; use libimagstore::storeid::IntoStoreId; use libimagstore::storeid::StoreId; diff --git a/bin/core/imag-git/Cargo.toml b/bin/core/imag-git/Cargo.toml index 168e04ce..af18fdfa 100644 --- a/bin/core/imag-git/Cargo.toml +++ b/bin/core/imag-git/Cargo.toml @@ -23,7 +23,7 @@ maintenance = { status = "actively-developed" } log = "0.4.6" toml = "0.5.1" toml-query = "0.9.2" -failure = "0.1.5" +anyhow = "1" libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" } libimagerror = { version = "0.10.0", path = "../../../lib/core/libimagerror" } diff --git a/bin/core/imag-git/src/lib.rs b/bin/core/imag-git/src/lib.rs index d839f986..94003d91 100644 --- a/bin/core/imag-git/src/lib.rs +++ b/bin/core/imag-git/src/lib.rs @@ -38,7 +38,7 @@ extern crate clap; #[macro_use] extern crate log; extern crate toml; extern crate toml_query; -#[macro_use] extern crate failure; +#[macro_use] extern crate anyhow; extern crate libimagrt; extern crate libimagerror; @@ -49,9 +49,9 @@ use std::process::Command; use toml::Value; use toml_query::read::TomlValueReadExt; use clap::App; |