diff options
Diffstat (limited to 'bin/core/imag-ref/src/lib.rs')
-rw-r--r-- | bin/core/imag-ref/src/lib.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/bin/core/imag-ref/src/lib.rs b/bin/core/imag-ref/src/lib.rs index bc41110f..c517b98c 100644 --- a/bin/core/imag-ref/src/lib.rs +++ b/bin/core/imag-ref/src/lib.rs @@ -36,7 +36,7 @@ #[macro_use] extern crate log; extern crate clap; -#[macro_use] extern crate failure; +#[macro_use] extern crate anyhow; extern crate libimagstore; extern crate libimagrt; @@ -49,9 +49,9 @@ mod ui; use std::io::Write; -use failure::Fallible as Result; -use failure::Error; -use failure::err_msg; +use anyhow::Result; +use anyhow::Error; + use clap::App; use libimagrt::application::ImagApplication; @@ -81,7 +81,7 @@ impl ImagApplication for ImagRef { if rt.handle_unknown_subcommand("imag-ref", other, rt.cli())?.success() { Ok(()) } else { - Err(format_err!("Subcommand failed")) + Err(anyhow!("Subcommand failed")) } }, } @@ -115,7 +115,7 @@ fn deref(rt: &Runtime) -> Result<()> { let mut outlock = out.lock(); rt.ids::<::ui::PathProvider>()? - .ok_or_else(|| err_msg("No ids supplied"))? + .ok_or_else(|| anyhow!("No ids supplied"))? .into_iter() .map(|id| { match rt.store().get(id.clone())? { @@ -128,12 +128,12 @@ fn deref(rt: &Runtime) -> Result<()> { r_entry.get_path(&cfg) }? .to_str() - .ok_or_else(|| Error::from(::libimagerror::errors::ErrorMsg::UTF8Error)) + .ok_or_else(|| anyhow!("Path is not valid UTF8")) .and_then(|s| writeln!(outlock, "{}", s).map_err(Error::from))?; rt.report_touched(&id) }, - None => Err(format_err!("No entry for id '{}' found", id)) + None => Err(anyhow!("No entry for id '{}' found", id)) } }) .collect() @@ -144,15 +144,15 @@ fn remove(rt: &Runtime) -> Result<()> { let cmd = rt.cli().subcommand_matches("remove").unwrap(); let yes = cmd.is_present("yes"); - 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(); rt.ids::<::ui::PathProvider>()? - .ok_or_else(|| err_msg("No ids supplied"))? + .ok_or_else(|| anyhow!("No ids supplied"))? .into_iter() .map(|id| { match rt.store().get(id.clone())? { - None => Err(format_err!("No entry for id '{}' found", id)), + None => Err(anyhow!("No entry for id '{}' found", id)), Some(mut entry) => { if yes || ask_bool(&format!("Delete ref from entry '{}'", id), None, &mut input, &mut output)? { entry.as_ref_with_hasher_mut::<DefaultHasher>().remove_ref() @@ -174,7 +174,7 @@ fn list_dead(rt: &Runtime) -> Result<()> { let mut output = rt.stdout(); rt.ids::<crate::ui::PathProvider>()? - .ok_or_else(|| err_msg("No ids supplied"))? + .ok_or_else(|| anyhow!("No ids supplied"))? .into_iter() .map(|id| { match rt.store().get(id.clone())? { @@ -202,7 +202,7 @@ fn list_dead(rt: &Runtime) -> Result<()> { } } - None => Err(format_err!("Does not exist: {}", id.local().display())), + None => Err(anyhow!("Does not exist: {}", id.local().display())), } }) .collect() |