summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-05-30 21:05:13 +0200
committerMatthias Beyer <mail@beyermatthias.de>2017-05-30 21:05:13 +0200
commit50c4c16aaf99e835afdebf09ac1d8a425cbc8fcb (patch)
treebdc38bc6d9f6eefc0227c1b3b5aa8ab8fd95d493
parenteacc6777b8e1dbead63eb3ba67385b25e342886e (diff)
downloadimag-50c4c16aaf99e835afdebf09ac1d8a425cbc8fcb.zip
imag-50c4c16aaf99e835afdebf09ac1d8a425cbc8fcb.tar.gz
Fix libimagdiary for new toml interface
-rw-r--r--libimagdiary/Cargo.toml1
-rw-r--r--libimagdiary/src/config.rs8
-rw-r--r--libimagdiary/src/lib.rs1
3 files changed, 7 insertions, 3 deletions
diff --git a/libimagdiary/Cargo.toml b/libimagdiary/Cargo.toml
index dc1e733..9139040 100644
--- a/libimagdiary/Cargo.toml
+++ b/libimagdiary/Cargo.toml
@@ -18,6 +18,7 @@ chrono = "0.2"
log = "0.3"
semver = "0.5"
toml = "0.4.*"
+toml-query = "0.1.*"
regex = "0.1"
lazy_static = "0.2"
itertools = "0.5"
diff --git a/libimagdiary/src/config.rs b/libimagdiary/src/config.rs
index b2e976a..a341b24 100644
--- a/libimagdiary/src/config.rs
+++ b/libimagdiary/src/config.rs
@@ -21,11 +21,13 @@ use toml::Value;
use libimagrt::runtime::Runtime;
+use toml_query::read::TomlValueReadExt;
+
pub fn get_default_diary_name(rt: &Runtime) -> Option<String> {
get_diary_config_section(rt)
.and_then(|config| {
- match config.lookup("default_diary") {
- Some(&Value::String(ref s)) => Some(s.clone()),
+ match config.read(&String::from("default_diary")) {
+ Ok(&Value::String(ref s)) => Some(s.clone()),
_ => 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> {
rt.config()
.map(|config| config.config())
- .and_then(|config| config.lookup("diary"))
+ .and_then(|config| config.read(&String::from("diary")).ok())
}
diff --git a/libimagdiary/src/lib.rs b/libimagdiary/src/lib.rs
index f675622..1dcd496 100644
--- a/libimagdiary/src/lib.rs
+++ b/libimagdiary/src/lib.rs
@@ -38,6 +38,7 @@ extern crate chrono;
#[macro_use] extern crate lazy_static;
extern crate semver;
extern crate toml;
+extern crate toml_query;
extern crate regex;
extern crate itertools;