diff options
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 19 |
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 @@ | |||
1 | use config::Config; | ||
2 | use once_cell::sync::Lazy; | ||
3 | |||
4 | pub static SETTINGS: Lazy<Config> = Lazy::new(setup); | ||
5 | |||
6 | fn 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 | } | ||