All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
34 lines
861 B
Rust
34 lines
861 B
Rust
use config::Config;
|
|
|
|
pub fn load_config() -> Config {
|
|
let global_config_path: String = find_global_config_path();
|
|
let home_config_path: String = find_home_config_path();
|
|
|
|
let settings = Config::builder()
|
|
// Add in `./Settings.toml`
|
|
.add_source(config::File::with_name(&global_config_path).required(false))
|
|
.add_source(config::File::with_name(&home_config_path).required(false))
|
|
.build()
|
|
.unwrap();
|
|
|
|
return settings;
|
|
}
|
|
|
|
fn find_global_config_path() -> String {
|
|
if cfg!(windows) {
|
|
return String::from("C:\\Program Files\\Zealot\\config.toml");
|
|
}
|
|
|
|
return String::from("/etc/zealot/config.toml");
|
|
}
|
|
|
|
fn find_home_config_path() -> String {
|
|
let home_path: &str = &shellexpand::tilde("~/.config/zealot.toml");
|
|
|
|
if cfg!(windows) {
|
|
return String::from(home_path.replace("/", "\\"));
|
|
}
|
|
|
|
return String::from(home_path);
|
|
}
|