configuration.rs: Add function to fetch editor options

This commit is contained in:
Matthias Beyer 2015-12-30 02:45:27 +01:00
parent 6ff2ac3567
commit 70fbd3914e

View file

@ -11,6 +11,7 @@ pub struct Configuration {
pub verbose : bool, pub verbose : bool,
pub debugging : bool, pub debugging : bool,
pub editor : Option<String>, pub editor : Option<String>,
pub editor_opts : String,
} }
impl Configuration { impl Configuration {
@ -22,6 +23,7 @@ impl Configuration {
let mut debugging = false; let mut debugging = false;
let mut store_sub = String::from("/store"); let mut store_sub = String::from("/store");
let mut editor = None; let mut editor = None;
let mut editor_opts = String::from("");
if let Some(cfg) = fetch_config(rtp.clone()) { if let Some(cfg) = fetch_config(rtp.clone()) {
if let Some(v) = cfg.lookup_boolean("verbose") { if let Some(v) = cfg.lookup_boolean("verbose") {
@ -36,6 +38,9 @@ impl Configuration {
if let Some(s) = cfg.lookup_str("editor") { if let Some(s) = cfg.lookup_str("editor") {
editor = Some(String::from(s)); editor = Some(String::from(s));
} }
if let Some(s) = cfg.lookup_str("editor-opts") {
editor_opts = String::from(s);
}
} }
let runtimepath = rtp.unwrap_or(String::from("/tmp/")); let runtimepath = rtp.unwrap_or(String::from("/tmp/"));
@ -46,6 +51,7 @@ impl Configuration {
debug!(" - store sub : {}", store_sub); debug!(" - store sub : {}", store_sub);
debug!(" - runtimepath: {}", runtimepath); debug!(" - runtimepath: {}", runtimepath);
debug!(" - editor : {}", editor.unwrap_or(String::from(""))); debug!(" - editor : {}", editor.unwrap_or(String::from("")));
debug!(" - editor-opts: {}", editor_opts);
Configuration { Configuration {
verbose: verbose, verbose: verbose,
@ -53,6 +59,7 @@ impl Configuration {
store_sub: store_sub, store_sub: store_sub,
rtp: runtimepath, rtp: runtimepath,
editor: editor, editor: editor,
editor_opts: editor_opts,
} }
} }
@ -76,6 +83,10 @@ impl Configuration {
self.editor self.editor
} }
pub fn editor_opts(&self) -> &String {
&self.editor_opts
}
} }
fn rtp_path(config: &CliConfig) -> Option<String> { fn rtp_path(config: &CliConfig) -> Option<String> {