feat: enhance AppConfig loading to merge default providers and set API key
This commit is contained in:
@@ -60,9 +60,15 @@ impl AppConfig {
|
||||
pub fn load() -> Self {
|
||||
let store = super::store::Store::new();
|
||||
let path = store.base_dir.join("app_config.json");
|
||||
std::fs::read_to_string(path)
|
||||
let mut cfg: AppConfig = std::fs::read_to_string(path)
|
||||
.ok()
|
||||
.and_then(|s| serde_json::from_str(&s).ok())
|
||||
.unwrap_or_default()
|
||||
.unwrap_or_default();
|
||||
// Merge any default providers not present in the loaded config
|
||||
let defaults = Self::default();
|
||||
for (name, provider) in defaults.providers {
|
||||
cfg.providers.entry(name).or_insert(provider);
|
||||
}
|
||||
cfg
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user