omni_dev/cli/git/
amend.rs1use anyhow::{Context, Result};
4use clap::Parser;
5
6#[derive(Parser)]
8pub struct AmendCommand {
9 #[arg(value_name = "YAML_FILE")]
11 pub yaml_file: String,
12}
13
14impl AmendCommand {
15 pub fn execute(self, repo: Option<&std::path::Path>) -> Result<()> {
20 use crate::git::AmendmentHandler;
21
22 let repo_root = match repo {
25 Some(p) => p.to_path_buf(),
26 None => std::env::current_dir().context("Failed to determine current directory")?,
27 };
28
29 crate::utils::check_git_repository_at(&repo_root)?;
31 crate::utils::check_working_directory_clean_at(&repo_root)?;
32
33 println!("🔄 Starting commit amendment process...");
34 println!("📄 Loading amendments from: {}", self.yaml_file);
35
36 let handler =
38 AmendmentHandler::new(&repo_root).context("Failed to initialize amendment handler")?;
39
40 handler
41 .apply_amendments(&self.yaml_file)
42 .context("Failed to apply amendments")?;
43
44 Ok(())
45 }
46}