fabro/crates/arc-attractor/src/cli/validate.rs
Bryan Helmkamp 32e4f5eb96 Rename all crates from unprefixed to arc-* prefix
Rename crate directories, package names, binary names, path
dependencies, use statements, qualified paths, clap command names,
and string literals across the workspace.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-28 04:20:47 -05:00

37 lines
1.1 KiB
Rust

use anyhow::bail;
use arc_util::terminal::Styles;
use crate::pipeline::PipelineBuilder;
use crate::validation::Severity;
use super::{print_diagnostics, read_dot_file, ValidateArgs};
/// Parse and validate a pipeline file without executing it.
///
/// # Errors
///
/// Returns an error if the file cannot be read, parsed, or has validation errors.
pub fn validate_command(args: &ValidateArgs, styles: &Styles) -> anyhow::Result<()> {
let source = read_dot_file(&args.pipeline)?;
let (graph, diagnostics) = PipelineBuilder::new().prepare(&source)?;
eprintln!(
"{bold}Parsed pipeline:{reset} {} ({dim}{} nodes, {} edges{reset})",
graph.name,
graph.nodes.len(),
graph.edges.len(),
bold = styles.bold, dim = styles.dim, reset = styles.reset,
);
print_diagnostics(&diagnostics, styles);
if diagnostics.iter().any(|d| d.severity == Severity::Error) {
bail!("Validation failed");
}
eprintln!(
"Validation: {green}OK{reset}",
green = styles.green, reset = styles.reset,
);
Ok(())
}