From b8c3f7f8346df790caec4d55303bfc65fe58b67b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 12 Mar 2018 23:20:13 +0100 Subject: [PATCH] Read editor from configuration, ignore errors --- lib/core/libimagrt/src/runtime.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/core/libimagrt/src/runtime.rs b/lib/core/libimagrt/src/runtime.rs index 8bc1cf70..7fe0a959 100644 --- a/lib/core/libimagrt/src/runtime.rs +++ b/lib/core/libimagrt/src/runtime.rs @@ -25,6 +25,7 @@ use std::io::Stdin; pub use clap::App; use toml::Value; +use toml_query::read::TomlValueReadExt; use clap::{Arg, ArgMatches}; @@ -457,7 +458,15 @@ impl<'a> Runtime<'a> { self.cli() .value_of("editor") .map(String::from) + .or_else(|| { + self.config() + .and_then(|v| match v.read("rt.editor") { + Ok(Some(&Value::String(ref s))) => Some(s.clone()), + _ => None, // FIXME silently ignore errors in config is bad + }) + }) .or(env::var("EDITOR").ok()) + .map(|s| {debug!("Editing with '{}'", s); s}) .map(|s| { let mut c = Command::new(s); c.stdin(::std::process::Stdio::inherit());