diff options
author | Caleb Bassi <calebjbassi@gmail.com> | 2019-01-31 07:08:52 -0800 |
---|---|---|
committer | Caleb Bassi <calebjbassi@gmail.com> | 2019-01-31 07:12:36 -0800 |
commit | b6b4f284ae1f1949de1e647aff6f2de7c3577cba (patch) | |
tree | e8502f9591c71c6345d91d359baa158dd16b4399 /src/main.rs | |
parent | 065ea17795144d91d475664e7a352b79530cb5d9 (diff) |
Cleanup config hierarchy; Only add ./config in debug mode
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 9ecfbf0..719ceea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,12 +9,28 @@ extern crate xdg; mod joshuto; +use std::path; + const PROGRAM_NAME: &str = "joshuto"; const CONFIG_FILE: &str = "joshuto.toml"; const MIMETYPE_FILE: &str = "mimetype.toml"; const KEYMAP_FILE: &str = "keymap.toml"; const THEME_FILE: &str = "theme.toml"; +lazy_static! { + static ref CONFIG_HIERARCHY: Vec<path::PathBuf> = { + let mut temp = vec![]; + match xdg::BaseDirectories::with_prefix(::PROGRAM_NAME) { + Ok(dirs) => temp.push(dirs.get_config_home()), + Err(e) => eprintln!("{}", e), + }; + if cfg!(debug_assertions) { + temp.push(path::PathBuf::from("./config")); + } + temp + }; +} + fn main() { let args: Vec<String> = std::env::args().collect(); |