forge-guard 0.1.0

Pre-deployment smart contract auditing framework for Foundry
Documentation
//! `forge ci` — generate CI/CD pipeline configurations.

use crate::ci::CiGenerator;

use super::CiArgs;
use anyhow::{Context, Result};
use colored::*;

/// Generate CI/CD pipeline configurations.
pub fn run(args: &CiArgs) -> Result<()> {
    let generator = CiGenerator::new(&args.platform);

    eprintln!("{}", "🔧 Forge Guard — CI/CD Generator".bold());
    eprintln!("   Platform: {}", args.platform.bold());

    // Generate the CI config
    let config = generator.generate(args.include_deploy)?;

    // Write to output directory
    let output_path = args.output.join(generator.filename());
    std::fs::create_dir_all(&args.output)?;

    if output_path.exists() && !args.overwrite {
        anyhow::bail!(
            "{} already exists. Use --overwrite to replace.",
            output_path.display()
        );
    }

    std::fs::write(&output_path, &config).context("Failed to write CI config")?;

    eprintln!(
        "{} CI config written to {}",
        "".green(),
        output_path.display()
    );
    println!("{}", config);

    Ok(())
}