summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2019-02-15 03:01:35 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2019-02-15 05:20:33 -0800
commit07f03353e27eb7df9a6e0f6457dd79bfd6ff4dac (patch)
tree1d9de82a4affd2621737c91421cce8346245c148 /src/main.rs
parentb35b77df864cd09836e8d9d5aa85064698addbb2 (diff)
refactor: config file handling
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index fb0648b..4627a29 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,7 +9,10 @@ extern crate xdg;
mod joshuto;
-use std::path;
+use std::env;
+use std::path::PathBuf;
+
+use joshuto::config::{JoshutoConfig, JoshutoKeymap};
const PROGRAM_NAME: &str = "joshuto";
const CONFIG_FILE: &str = "joshuto.toml";
@@ -19,21 +22,23 @@ const THEME_FILE: &str = "theme.toml";
const PREVIEW_FILE: &str = "preview.toml";
lazy_static! {
- static ref CONFIG_HIERARCHY: Vec<path::PathBuf> = {
+ // dynamically builds the config hierarchy
+ static ref CONFIG_HIERARCHY: Vec<PathBuf> = {
let mut temp = vec![];
- match xdg::BaseDirectories::with_prefix(::PROGRAM_NAME) {
+ match xdg::BaseDirectories::with_prefix(PROGRAM_NAME) {
Ok(dirs) => temp.push(dirs.get_config_home()),
Err(e) => eprintln!("{}", e),
};
+ // adds the default config files to the config hierarchy if running through cargo
if cfg!(debug_assertions) {
- temp.push(path::PathBuf::from("./config"));
+ temp.push(PathBuf::from("./config"));
}
temp
};
}
fn main() {
- let args: Vec<String> = std::env::args().collect();
+ let args: Vec<String> = env::args().collect();
for arg in &args {
if arg.as_str() == "-v" {
println!("{}", crate_version!());
@@ -41,8 +46,8 @@ fn main() {
}
}
- let config = joshuto::config::JoshutoConfig::get_config();
- let keymap = joshuto::config::JoshutoKeymap::get_config();
+ let config = JoshutoConfig::get_config();
+ let keymap = JoshutoKeymap::get_config();
joshuto::run(config, keymap);
}