summaryrefslogtreecommitdiffstats
path: root/src/joshuto/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/joshuto/config.rs')
-rw-r--r--src/joshuto/config.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/joshuto/config.rs b/src/joshuto/config.rs
index 7602b85..19c2132 100644
--- a/src/joshuto/config.rs
+++ b/src/joshuto/config.rs
@@ -1,7 +1,5 @@
extern crate serde;
-use self::serde::de::DeserializeOwned;
-
pub mod config;
pub mod keymap;
pub mod mimetype;
@@ -12,14 +10,15 @@ pub use self::config::JoshutoConfig;
pub use self::keymap::JoshutoKeymap;
pub use self::mimetype::JoshutoMimetype;
pub use self::preview::JoshutoPreview;
-pub use self::theme::JoshutoTheme;
-pub use self::theme::JoshutoColorTheme;
+pub use self::theme::{JoshutoColorTheme, JoshutoTheme};
+
+use self::serde::de::DeserializeOwned;
pub fn search_config_hierarchy(filename: &str) -> Option<std::path::PathBuf> {
for path in ::CONFIG_HIERARCHY.iter() {
let filepath = path.join(filename);
if filepath.exists() {
- return Some(filepath)
+ return Some(filepath);
}
}
None
@@ -32,7 +31,7 @@ fn read_config(filename: &str) -> Option<String> {
Err(e) => {
eprintln!("{}", e);
std::process::exit(1)
- },
+ }
}
}
@@ -41,7 +40,8 @@ trait Flattenable<T> {
}
fn parse_config<T, S>(filename: &str) -> Option<S>
- where T: DeserializeOwned + Flattenable<S>
+where
+ T: DeserializeOwned + Flattenable<S>,
{
let config_contents = read_config(filename)?;
let config = match toml::from_str::<T>(&config_contents) {
@@ -49,7 +49,7 @@ fn parse_config<T, S>(filename: &str) -> Option<S>
Err(e) => {
eprintln!("Error parsing {} file: {}", filename, e);
std::process::exit(1);
- },
+ }
};
Some(config.flatten())
}