From b4f59c226c6916a3e45f1a52dc6a9b15c800297a Mon Sep 17 00:00:00 2001 From: fx Date: Wed, 18 Oct 2023 15:11:44 +0200 Subject: basic cli, only start and get device --- src/config.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/config.rs (limited to 'src/config.rs') 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 @@ +use config::Config; +use once_cell::sync::Lazy; + +pub static SETTINGS: Lazy = 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() +} -- cgit v1.2.3