summaryrefslogtreecommitdiffstats
path: root/bin/core/imag-view
diff options
context:
space:
mode:
Diffstat (limited to 'bin/core/imag-view')
-rw-r--r--bin/core/imag-view/Cargo.toml2
-rw-r--r--bin/core/imag-view/src/lib.rs24
-rw-r--r--bin/core/imag-view/src/ui.rs2
3 files changed, 14 insertions, 14 deletions
diff --git a/bin/core/imag-view/Cargo.toml b/bin/core/imag-view/Cargo.toml
index 335b80d1..512d1f5b 100644
--- a/bin/core/imag-view/Cargo.toml
+++ b/bin/core/imag-view/Cargo.toml
@@ -25,7 +25,7 @@ toml = "0.5.1"
toml-query = "0.9.2"
handlebars = "2"
tempfile = "3.0.9"
-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-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))
}
diff --git a/bin/core/imag-view/src/ui.rs b/bin/core/imag-view/src/ui.rs
index a2f48360..607ab745 100644
--- a/bin/core/imag-view/src/ui.rs
+++ b/bin/core/imag-view/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;