use crate::prelude::*;
use ggen_core::dflss::{execute_dflss, DflssReport};
use ggen_core::manifest::ManifestParser;
use serde::Serialize;
use std::path::{Path, PathBuf};
#[derive(Debug, Serialize)]
pub struct SigmaOutput {
pub status: String,
pub methodology: String,
pub reports: Vec<DflssReport>,
pub overall_passed: bool,
}
#[verb("sigma", "root")]
pub fn sigma(phase: Option<String>) -> clap_noun_verb::Result<SigmaOutput> {
let manifest_path = PathBuf::from("ggen.toml");
let base_path = manifest_path.parent().unwrap_or(Path::new("."));
let manifest = ManifestParser::parse_and_validate(&manifest_path).map_err(|e| {
clap_noun_verb::NounVerbError::execution_error(format!("Failed to parse manifest: {}", e))
})?;
let reports = execute_dflss(&manifest, base_path, phase).map_err(|e| {
clap_noun_verb::NounVerbError::execution_error(format!("Gate execution failed: {}", e))
})?;
let overall_passed = reports.iter().all(|r| r.passed);
Ok(SigmaOutput {
status: if overall_passed {
"success".to_string()
} else {
"error".to_string()
},
methodology: "DMADV (DFLSS)".to_string(),
reports,
overall_passed,
})
}