summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
new file mode 100644
index 0000000..9a9e44b
--- /dev/null
+++ b/src/config.rs
@@ -0,0 +1,19 @@
1use config::Config;
2use once_cell::sync::Lazy;
3
4pub static SETTINGS: Lazy<Config> = Lazy::new(setup);
5
6fn setup() -> Config {
7 #[cfg(not(debug_assertions))]
8 let builder = Config::builder().add_source(config::File::with_name(
9 format!("{}/webol-cli.toml", dirs::config_dir().unwrap().to_string_lossy()).as_str(),
10 ));
11
12 #[cfg(debug_assertions)]
13 let builder = Config::builder().add_source(config::File::with_name("webol-cli.toml"));
14
15 builder
16 .add_source(config::Environment::with_prefix("WEBOL_CLI_").separator("_"))
17 .build()
18 .unwrap()
19}