diff options
Diffstat (limited to 'bin/core/imag/src/main.rs')
-rw-r--r-- | bin/core/imag/src/main.rs | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/bin/core/imag/src/main.rs b/bin/core/imag/src/main.rs index ae61e985..841c66ad 100644 --- a/bin/core/imag/src/main.rs +++ b/bin/core/imag/src/main.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 walkdir; extern crate toml; extern crate toml_query; @@ -56,10 +56,10 @@ use walkdir::WalkDir; use clap::{Arg, ArgMatches, AppSettings, SubCommand}; use toml::Value; use toml_query::read::TomlValueReadExt; -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 libimagrt::runtime::Runtime; use libimagrt::spec::CliSpec; @@ -144,9 +144,9 @@ fn main() -> Result<()> { // Initialize the Runtime and build the CLI let appname = ::std::env::current_exe()? .file_name() - .ok_or_else(|| format_err!("Program is not a file. This is a BUG, please file me."))? + .ok_or_else(|| anyhow!("Program is not a file. This is a BUG, please file me."))? .to_str() - .ok_or_else(|| format_err!("Program name is not UTF8. Whut?"))? + .ok_or_else(|| anyhow!("Program name is not UTF8. Whut?"))? .to_string(); let version = make_imag_version!(); let about = "imag - the PIM suite for the commandline"; @@ -172,7 +172,7 @@ fn main() -> Result<()> { let long_help = { let mut v = vec![]; app.write_long_help(&mut v)?; - String::from_utf8(v).map_err(|_| err_msg("UTF8 Error"))? + String::from_utf8(v).map_err(|_| anyhow!("UTF8 Error"))? }; let print_help = app.clone().get_matches().subcommand_name().map(|h| h == "help").unwrap_or(false); @@ -260,7 +260,7 @@ fn main() -> Result<()> { { Ok(exit_status) => if !exit_status.success() { debug!("imag-{} exited with non-zero exit code: {:?}", subcommand, exit_status); - Err(format_err!("imag-{} exited with non-zero exit code", subcommand)) + Err(anyhow!("imag-{} exited with non-zero exit code", subcommand)) } else { debug!("Successful exit!"); Ok(()) @@ -288,10 +288,10 @@ fn main() -> Result<()> { } fn fetch_aliases(config: Option<&Value>) -> Result<BTreeMap<String, String>> { - let cfg = config.ok_or_else(|| err_msg("No configuration found"))?; + let cfg = config.ok_or_else(|| anyhow!("No configuration found"))?; let value = cfg .read("imag.aliases") - .map_err(|_| err_msg("Reading from config failed"))?; + .map_err(|_| anyhow!("Reading from config failed"))?; match value { None => Ok(BTreeMap::new()), @@ -310,7 +310,7 @@ fn fetch_aliases(config: Option<&Value>) -> Result<BTreeMap<String, String>> { alias_mappings.insert(s.clone(), k.clone()); }, _ => { - let e = format_err!("Not all values are a String in 'imag.aliases.{}'", k); + let e = anyhow!("Not all values are a String in 'imag.aliases.{}'", k); return Err(e); } } @@ -318,7 +318,7 @@ fn fetch_aliases(config: Option<&Value>) -> Result<BTreeMap<String, String>> { }, _ => { - let msg = format_err!("Type Error: 'imag.aliases.{}' is not a table or string", k); + let msg = anyhow!("Type Error: 'imag.aliases.{}' is not a table or string", k); return Err(msg); }, } @@ -327,7 +327,7 @@ fn fetch_aliases(config: Option<&Value>) -> Result<BTreeMap<String, String>> { Ok(alias_mappings) }, - Some(_) => Err(err_msg("Type Error: 'imag.aliases' is not a table")), + Some(_) => Err(anyhow!("Type Error: 'imag.aliases' is not a table")), } } |