systemprompt_cli/commands/plugins/
mod.rs1pub mod types;
2
3mod capabilities;
4mod config;
5mod list;
6mod run;
7mod show;
8mod validate;
9
10pub mod mcp;
11
12use anyhow::{Context, Result};
13use clap::Subcommand;
14
15use crate::CliConfig;
16use crate::descriptor::{CommandDescriptor, DescribeCommand};
17use crate::shared::render_result;
18
19#[derive(Debug, Subcommand)]
20pub enum PluginsCommands {
21 #[command(about = "List all discovered extensions")]
22 List(list::ListArgs),
23
24 #[command(about = "Show detailed extension information")]
25 Show(show::ShowArgs),
26
27 #[command(about = "Run a CLI extension command", trailing_var_arg = true)]
28 Run(run::RunArgs),
29
30 #[command(about = "Validate extension dependencies and configurations")]
31 Validate(validate::ValidateArgs),
32
33 #[command(about = "Show extension configuration")]
34 Config(config::ConfigArgs),
35
36 #[command(about = "List capabilities across all extensions")]
37 Capabilities(capabilities::CapabilitiesArgs),
38
39 #[command(subcommand, about = "MCP server management")]
40 Mcp(mcp::McpCommands),
41}
42
43impl DescribeCommand for PluginsCommands {
44 fn descriptor(&self) -> CommandDescriptor {
45 match self {
46 Self::Mcp(
47 mcp::McpCommands::Logs(_) | mcp::McpCommands::ListPackages(_),
48 )
49 | Self::Run(_) => CommandDescriptor::PROFILE_ONLY,
50 Self::Mcp(_) => CommandDescriptor::FULL,
51 _ => CommandDescriptor::PROFILE_ONLY.with_remote_eligible(),
52 }
53 }
54}
55
56pub async fn execute(cmd: PluginsCommands, config: &CliConfig) -> Result<()> {
57 match cmd {
58 PluginsCommands::List(args) => {
59 render_result(&list::execute(&args, config));
60 Ok(())
61 },
62 PluginsCommands::Show(args) => {
63 let result = show::execute(&args, config).context("Failed to show extension")?;
64 render_result(&result);
65 Ok(())
66 },
67 PluginsCommands::Run(args) => run::execute(args, config).await,
68 PluginsCommands::Validate(args) => {
69 render_result(&validate::execute(&args, config));
70 Ok(())
71 },
72 PluginsCommands::Config(args) => {
73 let result =
74 config::execute(&args, config).context("Failed to get extension config")?;
75 render_result(&result);
76 Ok(())
77 },
78 PluginsCommands::Capabilities(args) => {
79 capabilities::execute(args, config);
80 Ok(())
81 },
82 PluginsCommands::Mcp(cmd) => mcp::execute_with_config(cmd, config).await,
83 }
84}