Simplify matching
This commit is contained in:
parent
131881cd01
commit
82c30edcee
1 changed files with 18 additions and 21 deletions
|
@ -393,38 +393,35 @@ fn aggregate_module_settings(_matches: &ArgMatches, config: Option<&Value>)
|
||||||
let mut settings = BTreeMap::new();
|
let mut settings = BTreeMap::new();
|
||||||
|
|
||||||
for (module_name, v) in t {
|
for (module_name, v) in t {
|
||||||
let destinations = match v.read("destinations") {
|
let destinations = match v.read("destinations")? {
|
||||||
Ok(Some(&Value::Array(ref a))) => translate_destinations(a).map(Some),
|
Some(&Value::Array(ref a)) => Some(translate_destinations(a)?),
|
||||||
Ok(None) => Ok(None),
|
None => None,
|
||||||
Ok(Some(_)) => {
|
Some(_) => {
|
||||||
let path = "imag.logging.modules.<mod>.destinations".to_owned();
|
let path = "imag.logging.modules.<mod>.destinations".to_owned();
|
||||||
let ty = "Array";
|
let ty = "Array";
|
||||||
Err(RE::from_kind(EK::ConfigTypeError(path, ty)))
|
return Err(RE::from_kind(EK::ConfigTypeError(path, ty)))
|
||||||
},
|
},
|
||||||
Err(e) => Err(e).map_err(From::from),
|
};
|
||||||
}?;
|
|
||||||
|
|
||||||
let level = match v.read("level") {
|
let level = match v.read("level")? {
|
||||||
Ok(Some(&Value::String(ref s))) => match_log_level_str(s).map(Some),
|
Some(&Value::String(ref s)) => Some(match_log_level_str(s)?),
|
||||||
Ok(None) => Ok(None),
|
None => None,
|
||||||
Ok(Some(_)) => {
|
Some(_) => {
|
||||||
let path = "imag.logging.modules.<mod>.level".to_owned();
|
let path = "imag.logging.modules.<mod>.level".to_owned();
|
||||||
let ty = "String";
|
let ty = "String";
|
||||||
Err(RE::from_kind(EK::ConfigTypeError(path, ty)))
|
return Err(RE::from_kind(EK::ConfigTypeError(path, ty)))
|
||||||
},
|
},
|
||||||
Err(e) => Err(e).map_err(From::from),
|
};
|
||||||
}?;
|
|
||||||
|
|
||||||
let enabled = match v.read("enabled") {
|
let enabled = match v.read("enabled")? {
|
||||||
Ok(Some(&Value::Boolean(b))) => Ok(b),
|
Some(&Value::Boolean(b)) => b,
|
||||||
Ok(None) => Ok(false),
|
None => false,
|
||||||
Ok(Some(_)) => {
|
Some(_) => {
|
||||||
let path = "imag.logging.modules.<mod>.enabled".to_owned();
|
let path = "imag.logging.modules.<mod>.enabled".to_owned();
|
||||||
let ty = "Boolean";
|
let ty = "Boolean";
|
||||||
Err(RE::from_kind(EK::ConfigTypeError(path, ty)))
|
return Err(RE::from_kind(EK::ConfigTypeError(path, ty)))
|
||||||
},
|
},
|
||||||
Err(e) => Err(e).map_err(From::from),
|
};
|
||||||
}?;
|
|
||||||
|
|
||||||
let module_settings = ModuleSettings {
|
let module_settings = ModuleSettings {
|
||||||
enabled: enabled,
|
enabled: enabled,
|
||||||
|
|
Loading…
Reference in a new issue