feat(commands):为所有命令添加config_path参数支持,实现自定义配置文件路径

♻️ refactor(config):重构ConfigManager,添加with_path_fresh方法用于初始化新配置
🔧 fix(git):改进跨平台路径处理,增强git仓库检测的鲁棒性
 test(tests):添加全面的集成测试,覆盖所有命令和跨平台场景
This commit is contained in:
2026-02-14 14:28:11 +08:00
parent 3c925d8268
commit e822ba1f54
14 changed files with 1152 additions and 272 deletions

View File

@@ -19,7 +19,11 @@ impl ConfigManager {
/// Create config manager with specific path
pub fn with_path(path: &Path) -> Result<Self> {
let config = AppConfig::load(path)?;
let config = if path.exists() {
AppConfig::load(path)?
} else {
AppConfig::default()
};
Ok(Self {
config,
config_path: path.to_path_buf(),
@@ -27,6 +31,15 @@ impl ConfigManager {
})
}
/// Create config manager with fresh config (ignoring existing)
pub fn with_path_fresh(path: &Path) -> Result<Self> {
Ok(Self {
config: AppConfig::default(),
config_path: path.to_path_buf(),
modified: true,
})
}
/// Get configuration reference
pub fn config(&self) -> &AppConfig {
&self.config