Fix calls to Runtime::config() to use direct result
This commit is contained in:
parent
eca7219039
commit
b237adfe19
7 changed files with 11 additions and 16 deletions
|
@ -99,7 +99,7 @@ fn main() {
|
|||
.map_err_trace_exit_unwrap(1);
|
||||
|
||||
let query = format!("view.viewers.{}", viewer);
|
||||
match config.config().read(&query) {
|
||||
match config.read(&query) {
|
||||
Err(e) => trace_error_exit(&e, 1),
|
||||
Ok(None) => {
|
||||
error!("Cannot find '{}' in config", query);
|
||||
|
|
|
@ -256,7 +256,6 @@ fn main() {
|
|||
fn fetch_aliases(rt: &Runtime) -> Result<BTreeMap<String, String>, String> {
|
||||
let cfg = try!(rt.config().ok_or_else(|| String::from("No configuration found")));
|
||||
let value = cfg
|
||||
.config()
|
||||
.read("imag.aliases")
|
||||
.map_err(|_| String::from("Reading from config failed"));
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ fn get_collection_name(rt: &Runtime,
|
|||
.and_then(|scmd| scmd.value_of(collection_argument_name).map(String::from))
|
||||
.unwrap_or_else(|| {
|
||||
rt.config()
|
||||
.map(|cfg| match cfg.config().read("bookmark.default_collection") {
|
||||
.map(|cfg| match cfg.read("bookmark.default_collection") {
|
||||
Err(e) => trace_error_exit(&e, 1),
|
||||
Ok(Some(&Value::String(ref name))) => name.clone(),
|
||||
Ok(None) => {
|
||||
|
|
|
@ -53,7 +53,6 @@ pub fn get_diary_timed_config(rt: &Runtime, diary_name: &str) -> Result<Option<T
|
|||
None => Ok(None),
|
||||
Some(cfg) => {
|
||||
let v = cfg
|
||||
.config()
|
||||
.read(&format!("diary.diaries.{}.timed", diary_name))
|
||||
.chain_err(|| DiaryErrorKind::IOError);
|
||||
|
||||
|
|
|
@ -34,10 +34,8 @@ 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| match config.read(&String::from("diary")) {
|
||||
Ok(x) => x,
|
||||
Err(_) => None,
|
||||
})
|
||||
rt.config().and_then(|config| match config.read(&String::from("diary")) {
|
||||
Ok(x) => x,
|
||||
Err(_) => None,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -34,9 +34,8 @@ pub struct Readline {
|
|||
impl Readline {
|
||||
|
||||
pub fn new(rt: &Runtime) -> Result<Readline> {
|
||||
let cfg = try!(rt.config().ok_or(IEK::NoConfigError));
|
||||
let c = try!(rt.config().ok_or(IEK::NoConfigError));
|
||||
|
||||
let c = cfg.config();
|
||||
let histfile = try!(c.lookup("ui.cli.readline_history_file").ok_or(IEK::ConfigError));
|
||||
let histsize = try!(c.lookup("ui.cli.readline_history_size").ok_or(IEK::ConfigError));
|
||||
let histigndups = try!(c.lookup("ui.cli.readline_history_ignore_dups").ok_or(IEK::ConfigError));
|
||||
|
|
|
@ -51,7 +51,8 @@ macro_rules! make_mock_app {
|
|||
use libimagrt::spec::CliSpec;
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagrt::error::RuntimeError;
|
||||
use libimagrt::configuration::{Configuration, InternalConfiguration};
|
||||
use libimagrt::configuration::InternalConfiguration;
|
||||
use toml::Value;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct MockLinkApp<'a> {
|
||||
|
@ -89,9 +90,8 @@ macro_rules! make_mock_app {
|
|||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn generate_minimal_test_config() -> Option<Configuration> { ::toml::de::from_str("[store]\nimplicit-create=true")
|
||||
.map(Configuration::with_value)
|
||||
.ok()
|
||||
pub fn generate_minimal_test_config() -> Option<Value> {
|
||||
::toml::de::from_str("[store]\nimplicit-create=true").ok()
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
|
|
Loading…
Reference in a new issue