mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-26 01:11:21 +00:00
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>
37 lines
1.1 KiB
Rust
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(())
|
|
}
|