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

@@ -13,13 +13,14 @@ use crate::i18n::{Messages, translate_changelog_category};
/// Generate changelog
#[derive(Parser)]
#[command(disable_version_flag = true, disable_help_flag = false)]
pub struct ChangelogCommand {
/// Output file path
#[arg(short, long)]
output: Option<PathBuf>,
/// Version to generate changelog for
#[arg(short, long)]
#[arg(long)]
version: Option<String>,
/// Generate from specific tag
@@ -51,7 +52,7 @@ pub struct ChangelogCommand {
include_authors: bool,
/// Format (keep-a-changelog, github-releases)
#[arg(short, long)]
#[arg(long)]
format: Option<String>,
/// Dry run (output to stdout)
@@ -64,9 +65,13 @@ pub struct ChangelogCommand {
}
impl ChangelogCommand {
pub async fn execute(&self) -> Result<()> {
pub async fn execute(&self, config_path: Option<PathBuf>) -> Result<()> {
let repo = find_repo(std::env::current_dir()?.as_path())?;
let manager = ConfigManager::new()?;
let manager = if let Some(ref path) = config_path {
ConfigManager::with_path(path)?
} else {
ConfigManager::new()?
};
let config = manager.config();
let language = manager.get_language().unwrap_or(Language::English);
let messages = Messages::new(language);