agentguard/commands/
schema.rs1use agentguard_core::{describe, 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 match store.load_schema()? {
8 Some(schema) => {
9 let summary = describe(&schema.source)?;
10 if output == "json" {
11 println!("{}", serde_json::to_string_pretty(&summary)?);
12 } else {
13 println!("entity types:");
14 for e in &summary.entities {
15 println!(" {}", e.name);
16 for a in &e.attributes {
17 let req = if a.required { "*" } else { "?" };
18 println!(" {}{}: {}", req, a.name, a.ty);
19 }
20 }
21 println!("actions:");
22 for a in &summary.actions {
23 println!(" Action::\"{}\"", a.name);
24 }
25 }
26 }
27 None => {
28 println!("no schema found at {}", store.schema_path().display());
29 }
30 }
31 Ok(())
32}