use ini::{Ini, Properties};
fn load(path: &str) -> Option<Ini> {
Ini::load_from_file(path).ok()
}
fn get_section(key: &str, cfg: &Ini) -> Option<Properties> {
cfg.section(Some(key)).map(|s| s.to_owned())
}
fn get_value_by_key(key: &str, prop: &Properties) -> Option<String> {
prop.get(key).map(String::from)
}
pub fn get_value(path: &str, section: &str, key: &str) -> Option<String> {
let cfg = load(path);
let sec = match cfg {
Some(c) => get_section(section, &c),
None => None,
};
match sec {
Some(c) => get_value_by_key(key, &c),
None => None,
}
}