summaryrefslogtreecommitdiff
path: root/src/config.rs
blob: 9a9e44b83e0b963f978f0d91f7da70ee1248557f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use config::Config;
use once_cell::sync::Lazy;

pub static SETTINGS: Lazy<Config> = Lazy::new(setup);

fn setup() -> Config {
    #[cfg(not(debug_assertions))]
    let builder = Config::builder().add_source(config::File::with_name(
        format!("{}/webol-cli.toml", dirs::config_dir().unwrap().to_string_lossy()).as_str(),
    ));

    #[cfg(debug_assertions)]
    let builder = Config::builder().add_source(config::File::with_name("webol-cli.toml"));

    builder
        .add_source(config::Environment::with_prefix("WEBOL_CLI_").separator("_"))
        .build()
        .unwrap()
}