Add Runtime functionality to patch in-memory-configuration-file-contents on loading application

This commit is contained in:
Matthias Beyer 2016-07-24 18:06:01 +02:00
parent 6f0670003b
commit 3eedab5206

View file

@ -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<String> {
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![])
}