systemprompt_cli/commands/plugins/capabilities/
schemas.rs1use clap::Args;
7
8use crate::CliConfig;
9use crate::commands::plugins::discover_registry;
10use crate::commands::plugins::types::{SchemaWithExtension, SchemasListOutput};
11use crate::shared::CommandOutput;
12
13#[derive(Debug, Clone, Args)]
14pub struct SchemasArgs {
15 #[arg(long, help = "Filter by extension ID")]
16 pub extension: Option<String>,
17}
18
19pub fn execute(args: &SchemasArgs, _config: &CliConfig) -> CommandOutput {
20 let registry = discover_registry();
21
22 let schemas: Vec<SchemaWithExtension> = registry
23 .extensions()
24 .iter()
25 .filter(|ext| args.extension.as_ref().is_none_or(|f| ext.id().contains(f)))
26 .flat_map(|ext| {
27 ext.schemas()
28 .iter()
29 .map(|schema| SchemaWithExtension {
30 extension_id: systemprompt_identifiers::PluginId::new(ext.id()),
31 extension_name: ext.name().to_owned(),
32 table: schema.table.clone(),
33 source: "inline".to_owned(),
34 })
35 .collect::<Vec<_>>()
36 })
37 .collect();
38
39 let total = schemas.len();
40
41 let output = SchemasListOutput { schemas, total };
42
43 CommandOutput::table_of(vec!["extension_id", "table", "source"], &output.schemas)
44 .with_title("Schemas Across Extensions")
45}