diff options
Diffstat (limited to 'bin/core/imag-gps')
-rw-r--r-- | bin/core/imag-gps/Cargo.toml | 2 | ||||
-rw-r--r-- | bin/core/imag-gps/src/lib.rs | 30 | ||||
-rw-r--r-- | bin/core/imag-gps/src/ui.rs | 4 |
3 files changed, 18 insertions, 18 deletions
diff --git a/bin/core/imag-gps/Cargo.toml b/bin/core/imag-gps/Cargo.toml index 5c197e7d..8b09b751 100644 --- a/bin/core/imag-gps/Cargo.toml +++ b/bin/core/imag-gps/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" libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" } libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" } diff --git a/bin/core/imag-gps/src/lib.rs b/bin/core/imag-gps/src/lib.rs index 3cb2deff..594f5926 100644 --- a/bin/core/imag-gps/src/lib.rs +++ b/bin/core/imag-gps/src/lib.rs @@ -36,7 +36,7 @@ extern crate clap; #[macro_use] extern crate log; -#[macro_use] extern crate failure; +#[macro_use] extern crate anyhow; extern crate libimagentrygps; extern crate libimagrt; @@ -47,9 +47,9 @@ extern crate libimagstore; use std::io::Write; use std::str::FromStr; -use failure::Error; -use failure::Fallible as Result; -use failure::err_msg; +use anyhow::Error; +use anyhow::Result; + use clap::App; use libimagstore::storeid::StoreId; @@ -67,7 +67,7 @@ mod ui; pub enum ImagGps {} impl ImagApplication for ImagGps { 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"))? { "add" => add(&rt), "remove" => remove(&rt), "get" => get(&rt), @@ -79,7 +79,7 @@ impl ImagApplication for ImagGps { { Ok(()) } else { - Err(format_err!("Subcommand failed")) + Err(anyhow!("Subcommand failed")) } } } @@ -105,7 +105,7 @@ impl ImagApplication for ImagGps { fn rt_get_ids(rt: &Runtime) -> Result<Vec<StoreId>> { rt .ids::<crate::ui::PathProvider>()? - .ok_or_else(|| err_msg("No ids supplied")) + .ok_or_else(|| anyhow!("No ids supplied")) } fn add(rt: &Runtime) -> Result<()> { @@ -115,11 +115,11 @@ fn add(rt: &Runtime) -> Result<()> { let ary = value.split('.') .map(|v| {debug!("Parsing = {}", v); v}) .map(FromStr::from_str) - .map(|elem| elem.or_else(|_| Err(err_msg("Error while converting number")))) + .map(|elem| elem.or_else(|_| Err(anyhow!("Error while converting number")))) .collect::<Result<Vec<i64>>>()?; - let degree = ary.get(0).ok_or_else(|| err_msg("Degree missing. This value is required."))?; - let minute = ary.get(1).ok_or_else(|| err_msg("Degree missing. This value is required."))?; + let degree = ary.get(0).ok_or_else(|| anyhow!("Degree missing. This value is required."))?; + let minute = ary.get(1).ok_or_else(|| anyhow!("Degree missing. This value is required."))?; let second = ary.get(2).unwrap_or(&0); Ok((*degree, *minute, *second)) @@ -141,7 +141,7 @@ fn add(rt: &Runtime) -> Result<()> { .map(|id| { rt.store() .get(id.clone())? - .ok_or_else(|| format_err!("No such entry: {}", id))? + .ok_or_else(|| anyhow!("No such entry: {}", id))? .set_coordinates(c.clone())?; rt.report_touched(&id) @@ -162,9 +162,9 @@ fn remove(rt: &Runtime) -> Result<()> { let removed_value : Coordinates = rt .store() .get(id.clone())? - .ok_or_else(|| format_err!("No such entry: {}", id))? + .ok_or_else(|| anyhow!("No such entry: {}", id))? .remove_coordinates()? - .ok_or_else(|| format_err!("Entry had no coordinates: {}", id))??; + .ok_or_else(|| anyhow!("Entry had no coordinates: {}", id))??; if print_removed { writeln!(rt.stdout(), "{}", removed_value)?; @@ -185,11 +185,11 @@ fn get(rt: &Runtime) -> Result<()> { .store() .get(id.clone())? .ok_or_else(|| { // if we have Ok(None) - format_err!("No such entry: {}", id) + anyhow!("No such entry: {}", id) })? .get_coordinates()? .ok_or_else(|| { // if we have Ok(None) - format_err!("Entry has no coordinates: {}", id) + anyhow!("Entry has no coordinates: {}", id) })?; writeln!(stdout, "{}", value)?; diff --git a/bin/core/imag-gps/src/ui.rs b/bin/core/imag-gps/src/ui.rs index f76d71b5..1abc924e 100644 --- a/bin/core/imag-gps/src/ui.rs +++ b/bin/core/imag-gps/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::IntoStoreId; use libimagstore::storeid::StoreId; @@ -114,7 +114,7 @@ impl IdPathProvider for PathProvider { ("add", Some(subm)) => get_id_paths("entry", subm), ("remove", Some(subm)) => get_id_paths("entry", 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)), } } } |