From 3eedab52064011f219d718bb0fff71ed41e7e1a3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 24 Jul 2016 18:06:01 +0200 Subject: [PATCH] Add Runtime functionality to patch in-memory-configuration-file-contents on loading application --- libimagrt/src/runtime.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index e5b31898..63678672 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -88,7 +88,16 @@ impl<'a> Runtime<'a> { None }, - Ok(cfg) => Some(cfg), + Ok(mut cfg) => { + if let Err(e) = cfg.override_config(get_override_specs(&matches)) { + error!("Could not apply config overrides"); + trace_error(&e); + + // TODO: continue question (interactive) + } + + Some(cfg) + } }; let store_config = match cfg { @@ -291,3 +300,19 @@ impl<'a> Runtime<'a> { } } +fn get_override_specs(matches: &ArgMatches) -> Vec { + matches + .values_of("config-override") + .map(|values| { + values + .filter(|s| { + let b = s.contains("="); + if !b { warn!("override '{}' does not contain '=' - will be ignored!", s); } + b + }) + .map(String::from) + .collect() + }) + .unwrap_or(vec![]) +} +