Skip to main content

omni_dev/cli/git/
amend.rs

1//! Amend command — applies commit message amendments from a YAML file.
2
3use anyhow::{Context, Result};
4use clap::Parser;
5
6/// Amend command options.
7#[derive(Parser)]
8pub struct AmendCommand {
9    /// YAML file containing commit amendments.
10    #[arg(value_name = "YAML_FILE")]
11    pub yaml_file: String,
12}
13
14impl AmendCommand {
15    /// Executes the amend command.
16    pub fn execute(self) -> Result<()> {
17        use crate::git::AmendmentHandler;
18
19        // Preflight checks: validate prerequisites before any processing
20        crate::utils::check_git_repository()?;
21        crate::utils::check_working_directory_clean()?;
22
23        println!("🔄 Starting commit amendment process...");
24        println!("📄 Loading amendments from: {}", self.yaml_file);
25
26        // Create amendment handler and apply amendments
27        let handler = AmendmentHandler::new().context("Failed to initialize amendment handler")?;
28
29        handler
30            .apply_amendments(&self.yaml_file)
31            .context("Failed to apply amendments")?;
32
33        Ok(())
34    }
35}