Add extensive debugging output in utilities
This commit is contained in:
parent
1517d6f310
commit
ef18cb1144
1 changed files with 17 additions and 2 deletions
|
@ -26,7 +26,15 @@ pub fn build_toml_header(matches: &ArgMatches, mut header: EntryHeader) -> Entry
|
|||
debug!("Building header from cli spec");
|
||||
if let Some(headerspecs) = matches.values_of("header") {
|
||||
let mut main = header.toml_mut();
|
||||
for tpl in headerspecs.into_iter().filter_map(|hs| String::from(hs).into_kv()) {
|
||||
debug!("headerspec = {:?}", headerspecs);
|
||||
let kvs = headerspecs.into_iter()
|
||||
.filter_map(|hs| {
|
||||
debug!("- Processing: '{}'", hs);
|
||||
let kv = String::from(hs).into_kv();
|
||||
debug!("- got: '{:?}'", kv);
|
||||
kv
|
||||
});
|
||||
for tpl in kvs {
|
||||
let (key, value) = tpl.into();
|
||||
debug!("Splitting: {:?}", key);
|
||||
let mut split = key.split(".");
|
||||
|
@ -36,6 +44,7 @@ pub fn build_toml_header(matches: &ArgMatches, mut header: EntryHeader) -> Entry
|
|||
}
|
||||
}
|
||||
}
|
||||
debug!("Header = {:?}", header);
|
||||
header
|
||||
}
|
||||
|
||||
|
@ -46,8 +55,10 @@ fn insert_key_into(current: String,
|
|||
let next = rest_path.next();
|
||||
|
||||
if next.is_none() {
|
||||
debug!("Inserting into {:?} = {:?}", current, value);
|
||||
map.insert(current, parse_value(value));
|
||||
} else {
|
||||
debug!("Inserting into {:?} ... = {:?}", current, value);
|
||||
if map.contains_key(¤t) {
|
||||
match map.get_mut(¤t).unwrap() {
|
||||
&mut Value::Table(ref mut t) => {
|
||||
|
@ -58,6 +69,7 @@ fn insert_key_into(current: String,
|
|||
} else {
|
||||
let mut submap = BTreeMap::new();
|
||||
insert_key_into(String::from(next.unwrap()), rest_path, value, &mut submap);
|
||||
debug!("Inserting submap = {:?}", submap);
|
||||
map.insert(current, Value::Table(submap));
|
||||
}
|
||||
}
|
||||
|
@ -68,15 +80,18 @@ fn parse_value(value: String) -> Value {
|
|||
v.chars().next() == Some('[') && v.chars().last() == Some(']') && v.len() >= 3
|
||||
}
|
||||
|
||||
debug!("Building value out of: {:?}", value);
|
||||
if value == "true" {
|
||||
debug!("Building Boolean out of: {:?}...", value);
|
||||
Value::Boolean(true)
|
||||
} else if value == "false" {
|
||||
debug!("Building Boolean out of: {:?}...", value);
|
||||
Value::Boolean(false)
|
||||
} else if is_ary(&value) {
|
||||
debug!("Building Array out of: {:?}...", value);
|
||||
let sub = &value[1..(value.len()-1)];
|
||||
Value::Array(sub.split(",").map(|v| parse_value(String::from(v))).collect())
|
||||
} else {
|
||||
debug!("Building String out of: {:?}...", value);
|
||||
Value::String(value)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue