feat: enhance AppConfig loading to merge default providers and set API key

This commit is contained in:
asepharyana
2026-07-12 02:21:08 +07:00
parent c948869d35
commit a98fdb0c7b
2 changed files with 14 additions and 2 deletions
+8 -2
View File
@@ -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
}
}