agentguard/commands/
validate.rs1use agentguard_core::PolicyStore;
2use anyhow::Result;
3use std::path::Path;
4
5pub fn run(store: impl AsRef<Path>, _output: &str) -> Result<()> {
6 let store = PolicyStore::open(store)?;
7 let report = store.validate()?;
8 println!("Loaded {} policies.", report.policy_count);
9 if report.errors.is_empty() && report.warnings.is_empty() {
10 println!("✓ no errors, no warnings");
11 }
12 let is_ok = report.is_ok();
13 for w in &report.warnings {
14 println!(" warn {}: {}", w.policy, w.message);
15 }
16 for e in &report.errors {
17 println!(" ERR {}: {}", e.policy, e.message);
18 }
19 if !is_ok {
20 std::process::exit(1);
21 }
22 Ok(())
23}