summaryrefslogtreecommitdiffstats
path: root/bin/core/imag-view/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/core/imag-view/src/lib.rs')
-rw-r--r--bin/core/imag-view/src/lib.rs24
1 files changed, 12 insertions, 12 deletions
diff --git a/bin/core/imag-view/src/lib.rs b/bin/core/imag-view/src/lib.rs
index 3f30f477..eed3e12a 100644
--- a/bin/core/imag-view/src/lib.rs
+++ b/bin/core/imag-view/src/lib.rs
@@ -40,7 +40,7 @@ extern crate handlebars;
extern crate tempfile;
extern crate toml;
extern crate toml_query;
-#[macro_use] extern crate failure;
+#[macro_use] extern crate anyhow;
extern crate resiter;
extern crate libimagentryview;
@@ -56,8 +56,8 @@ use std::process::Command;
use handlebars::Handlebars;
use toml_query::read::TomlValueReadTypeExt;
-use failure::err_msg;
-use failure::Fallible as Result;
+
+use anyhow::Result;
use resiter::AndThen;
use resiter::IterInnerOkOrElse;
use clap::App;
@@ -83,11 +83,11 @@ impl ImagApplication for ImagView {
let hide_content = rt.cli().is_present("not-view-content");
let entries = rt
.ids::<::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("Entry not found, please report this as a bug"));
+ .map_inner_ok_or_else(|| anyhow!("Entry not found, please report this as a bug"));
if rt.cli().is_present("in") {
let files = entries
@@ -102,17 +102,17 @@ impl ImagApplication for ImagView {
let viewer = rt
.cli()
.value_of("in")
- .ok_or_else(|| err_msg("No viewer given"))?;
+ .ok_or_else(|| anyhow!("No viewer given"))?;
let config = rt
.config()
- .ok_or_else(|| err_msg("No configuration, cannot continue"))?;
+ .ok_or_else(|| anyhow!("No configuration, cannot continue"))?;
let query = format!("view.viewers.{}", viewer);
let viewer_template = config
.read_string(&query)?
- .ok_or_else(|| format_err!("Cannot find '{}' in config", query))?;
+ .ok_or_else(|| anyhow!("Cannot find '{}' in config", query))?;
let mut handlebars = Handlebars::new();
handlebars.register_escape_fn(::handlebars::no_escape);
@@ -131,7 +131,7 @@ impl ImagApplication for ImagView {
let call = handlebars .render("template", &data)?;
let mut elems = call.split_whitespace();
- let command_string = elems.next().ok_or_else(|| err_msg("No command"))?;
+ let command_string = elems.next().ok_or_else(|| anyhow!("No command"))?;
let mut cmd = Command::new(command_string);
for arg in elems {
@@ -147,7 +147,7 @@ impl ImagApplication for ImagView {
.status()?
.success()
{
- return Err(err_msg("Failed to execute command"))
+ return Err(anyhow!("Failed to execute command"))
}
drop(files);
@@ -194,7 +194,7 @@ impl ImagApplication for ImagView {
if rt.cli().occurrences_of("autowrap") != 0 {
let width = rt.cli().value_of("autowrap").unwrap(); // ensured by clap
let width = usize::from_str(width).map_err(|_| {
- format_err!("Failed to parse argument to number: autowrap = {:?}",
+ anyhow!("Failed to parse argument to number: autowrap = {:?}",
rt.cli().value_of("autowrap").map(String::from))
})?;
@@ -258,7 +258,7 @@ fn create_tempfile_for<'a>(entry: &FileLockEntry<'a>, view_header: bool, hide_co
.path()
.to_str()
.map(String::from)
- .ok_or_else(|| err_msg("Cannot build path"))?;
+ .ok_or_else(|| anyhow!("Cannot build path"))?;
Ok((tmpfile, file_path))
}