imag-bookmark: Replace read with typed read
This commit is contained in:
parent
0a78d43741
commit
137680498c
1 changed files with 10 additions and 15 deletions
|
@ -44,8 +44,7 @@ extern crate libimagutil;
|
||||||
|
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
use toml::Value;
|
use toml_query::read::TomlValueReadTypeExt;
|
||||||
use toml_query::read::TomlValueReadExt;
|
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagrt::setup::generate_runtime_setup;
|
use libimagrt::setup::generate_runtime_setup;
|
||||||
|
@ -177,19 +176,15 @@ fn get_collection_name(rt: &Runtime,
|
||||||
.and_then(|scmd| scmd.value_of(collection_argument_name).map(String::from))
|
.and_then(|scmd| scmd.value_of(collection_argument_name).map(String::from))
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
rt.config()
|
rt.config()
|
||||||
.map(|cfg| match cfg.read("bookmark.default_collection") {
|
.map(|cfg| {
|
||||||
Err(e) => trace_error_exit(&e, 1),
|
cfg.read_string("bookmark.default_collection")
|
||||||
Ok(Some(&Value::String(ref name))) => name.clone(),
|
.map_err_trace_exit_unwrap(1)
|
||||||
Ok(None) => {
|
.ok_or_else(|| {
|
||||||
error!("Missing config: 'bookmark.default_collection'. Set or use commandline to specify.");
|
error!("Missing config: 'bookmark.default_collection'. Set or use commandline to specify.");
|
||||||
exit(1)
|
exit(1)
|
||||||
},
|
})
|
||||||
|
.unwrap()
|
||||||
Ok(Some(_)) => {
|
.clone()
|
||||||
error!("Type error in configuration: 'bookmark.default_collection' should be string");
|
|
||||||
exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
error!("Failed to read configuration");
|
error!("Failed to read configuration");
|
||||||
|
|
Loading…
Reference in a new issue