Added some fixes for Windows (now the setup command works)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -1,12 +1,36 @@
|
||||
use std::path::Path;
|
||||
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();
|
||||
|
||||
println!("{}", Path::new(&global_config_path).exists());
|
||||
|
||||
let settings = Config::builder()
|
||||
// Add in `./Settings.toml`
|
||||
.add_source(config::File::with_name("/etc/zealot/config.toml").required(false))
|
||||
.add_source(config::File::with_name(&shellexpand::tilde("~/.config/zealot.toml")).required(false))
|
||||
.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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user