use anyhow::{Context, Result};
use clap::Parser;
#[derive(Parser)]
pub struct AmendCommand {
#[arg(value_name = "YAML_FILE")]
pub yaml_file: String,
}
impl AmendCommand {
pub fn execute(self, repo: Option<&std::path::Path>) -> Result<()> {
use crate::git::AmendmentHandler;
let repo_root = match repo {
Some(p) => p.to_path_buf(),
None => std::env::current_dir().context("Failed to determine current directory")?,
};
crate::utils::check_git_repository_at(&repo_root)?;
crate::utils::check_working_directory_clean_at(&repo_root)?;
println!("🔄 Starting commit amendment process...");
println!("📄 Loading amendments from: {}", self.yaml_file);
let handler =
AmendmentHandler::new(&repo_root).context("Failed to initialize amendment handler")?;
handler
.apply_amendments(&self.yaml_file)
.context("Failed to apply amendments")?;
Ok(())
}
}