summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-mail/src/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bin/domain/imag-mail/src/util.rs')
-rw-r--r--bin/domain/imag-mail/src/util.rs45
1 files changed, 1 insertions, 44 deletions
diff --git a/bin/domain/imag-mail/src/util.rs b/bin/domain/imag-mail/src/util.rs
index f7079849..506bfc7a 100644
--- a/bin/domain/imag-mail/src/util.rs
+++ b/bin/domain/imag-mail/src/util.rs
@@ -19,39 +19,12 @@
use std::collections::BTreeMap;
use std::io::Write;
-use std::path::PathBuf;
-
-use clap::ArgMatches;
-use anyhow::Error;
-use anyhow::Result;
+use failure::Fallible as Result;
use handlebars::Handlebars;
-use toml_query::read::TomlValueReadTypeExt;
use libimaginteraction::format::HandlebarsData;
use libimagmail::mail::ParsedMail;
-use libimagrt::runtime::Runtime;
-
-pub fn get_mail_print_format<'rc>(config_value_path: &'static str, rt: &Runtime, scmd: &ArgMatches) -> Result<Handlebars<'rc>> {
- let fmt = match scmd.value_of("format").map(String::from) {
- Some(s) => Ok(s),
- None => {
- rt.config()
- .ok_or_else(|| anyhow!("No configuration file"))?
- .read_string(config_value_path)
- .map_err(Error::from)?
- .ok_or_else(|| anyhow!("Configuration '{}' does not exist", config_value_path))
- }
- }?;
-
- let mut hb = Handlebars::new();
- hb.register_template_string("format", fmt)?;
-
- hb.register_escape_fn(::handlebars::no_escape);
- ::libimaginteraction::format::register_all_color_helpers(&mut hb);
- ::libimaginteraction::format::register_all_format_helpers(&mut hb);
- Ok(hb)
-}
pub fn build_data_object_for_handlebars(i: usize, m: &ParsedMail) -> Result<BTreeMap<&'static str, HandlebarsData>> {
let mut data = BTreeMap::new();
@@ -95,19 +68,3 @@ pub fn list_mail(m: &ParsedMail, i: usize, indent: usize, list_format: &Handleba
Ok(())
}
-pub fn get_notmuch_database_path(rt: &Runtime) -> Result<PathBuf> {
- if let Some(pb) = rt.cli()
- .value_of("database_path")
- .map(String::from)
- .map(PathBuf::from)
- {
- return Ok(pb)
- } else {
- rt.config()
- .ok_or_else(|| err_msg("No configuration file"))?
- .read_string("mail.notmuch_database")
- .map_err(Error::from)?
- .map(PathBuf::from)
- .ok_or_else(|| format_err!("Configuration 'mail.notmuch_database' does not exist"))
- }
-}