spec_driven_docs/commands/
gate.rs1use crate::cli::gate::GateArgs;
8use crate::context::AppContext;
9use crate::error::AppError;
10use crate::gates::{GateCtx, spec};
11use crate::output;
12
13pub fn run(_ctx: &AppContext, args: GateArgs) -> Result<(), AppError> {
20 let GateArgs { id, files, list } = args;
21 if list {
22 for gate in crate::gates::GATES {
23 output::line(format!("{}: {}", gate.id, gate.name));
24 }
25 return Ok(());
26 }
27 let Some(id) = id else {
28 return Err(AppError::Usage(
29 "a gate id or --list is required".to_string(),
30 ));
31 };
32 let gate_ctx = GateCtx::new(".");
33 let violations = (spec(id).run)(&gate_ctx, &files)?;
34 if violations.is_empty() {
35 return Ok(());
36 }
37 for violation in &violations {
38 output::line(violation);
39 }
40 Err(AppError::Violations {
41 count: violations.len(),
42 })
43}