Fix libimagdiary for new toml interface
This commit is contained in:
parent
eacc6777b8
commit
50c4c16aaf
3 changed files with 7 additions and 3 deletions
|
@ -18,6 +18,7 @@ chrono = "0.2"
|
||||||
log = "0.3"
|
log = "0.3"
|
||||||
semver = "0.5"
|
semver = "0.5"
|
||||||
toml = "0.4.*"
|
toml = "0.4.*"
|
||||||
|
toml-query = "0.1.*"
|
||||||
regex = "0.1"
|
regex = "0.1"
|
||||||
lazy_static = "0.2"
|
lazy_static = "0.2"
|
||||||
itertools = "0.5"
|
itertools = "0.5"
|
||||||
|
|
|
@ -21,11 +21,13 @@ use toml::Value;
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
|
|
||||||
|
use toml_query::read::TomlValueReadExt;
|
||||||
|
|
||||||
pub fn get_default_diary_name(rt: &Runtime) -> Option<String> {
|
pub fn get_default_diary_name(rt: &Runtime) -> Option<String> {
|
||||||
get_diary_config_section(rt)
|
get_diary_config_section(rt)
|
||||||
.and_then(|config| {
|
.and_then(|config| {
|
||||||
match config.lookup("default_diary") {
|
match config.read(&String::from("default_diary")) {
|
||||||
Some(&Value::String(ref s)) => Some(s.clone()),
|
Ok(&Value::String(ref s)) => Some(s.clone()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -34,5 +36,5 @@ pub fn get_default_diary_name(rt: &Runtime) -> Option<String> {
|
||||||
pub fn get_diary_config_section<'a>(rt: &'a Runtime) -> Option<&'a Value> {
|
pub fn get_diary_config_section<'a>(rt: &'a Runtime) -> Option<&'a Value> {
|
||||||
rt.config()
|
rt.config()
|
||||||
.map(|config| config.config())
|
.map(|config| config.config())
|
||||||
.and_then(|config| config.lookup("diary"))
|
.and_then(|config| config.read(&String::from("diary")).ok())
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ extern crate chrono;
|
||||||
#[macro_use] extern crate lazy_static;
|
#[macro_use] extern crate lazy_static;
|
||||||
extern crate semver;
|
extern crate semver;
|
||||||
extern crate toml;
|
extern crate toml;
|
||||||
|
extern crate toml_query;
|
||||||
extern crate regex;
|
extern crate regex;
|
||||||
extern crate itertools;
|
extern crate itertools;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue