chore: apply cargo fmt before release

- Format code in app_config.rs to comply with rustfmt rules
- Remove extra blank line in config.rs
- Format test code in app_config_load.rs for consistency
This commit is contained in:
Jason
2025-11-06 16:32:45 +08:00
parent 69c0a09604
commit 03e15916dd
3 changed files with 5 additions and 10 deletions

View File

@@ -107,14 +107,8 @@ impl MultiAppConfig {
let value: serde_json::Value = let value: serde_json::Value =
serde_json::from_str(&content).map_err(|e| AppError::json(&config_path, e))?; serde_json::from_str(&content).map_err(|e| AppError::json(&config_path, e))?;
let is_v1 = value.as_object().is_some_and(|map| { let is_v1 = value.as_object().is_some_and(|map| {
let has_providers = map let has_providers = map.get("providers").map(|v| v.is_object()).unwrap_or(false);
.get("providers") let has_current = map.get("current").map(|v| v.is_string()).unwrap_or(false);
.map(|v| v.is_object())
.unwrap_or(false);
let has_current = map
.get("current")
.map(|v| v.is_string())
.unwrap_or(false);
// v1 的充分必要条件:有 providers 和 current且 apps 不存在version/mcp 可能存在但不作为 v2 判据) // v1 的充分必要条件:有 providers 和 current且 apps 不存在version/mcp 可能存在但不作为 v2 判据)
let has_apps = map.contains_key("apps"); let has_apps = map.contains_key("apps");
has_providers && has_current && !has_apps has_providers && has_current && !has_apps

View File

@@ -78,7 +78,6 @@ pub fn get_app_config_path() -> PathBuf {
get_app_config_dir().join("config.json") get_app_config_dir().join("config.json")
} }
/// 清理供应商名称,确保文件名安全 /// 清理供应商名称,确保文件名安全
pub fn sanitize_provider_name(name: &str) -> String { pub fn sanitize_provider_name(name: &str) -> String {
name.chars() name.chars()

View File

@@ -100,6 +100,8 @@ fn load_valid_v2_config_succeeds() {
let loaded = MultiAppConfig::load().expect("v2 should load successfully"); let loaded = MultiAppConfig::load().expect("v2 should load successfully");
assert_eq!(loaded.version, 2); assert_eq!(loaded.version, 2);
assert!(loaded.get_manager(&cc_switch_lib::AppType::Claude).is_some()); assert!(loaded
.get_manager(&cc_switch_lib::AppType::Claude)
.is_some());
assert!(loaded.get_manager(&cc_switch_lib::AppType::Codex).is_some()); assert!(loaded.get_manager(&cc_switch_lib::AppType::Codex).is_some());
} }