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(mcp::McpCommands::Logs(_) | mcp::McpCommands::ListPackages(_))
47 | Self::Run(_) => CommandDescriptor::PROFILE_ONLY,
48 Self::Mcp(_) => CommandDescriptor::FULL,
49 _ => CommandDescriptor::PROFILE_ONLY.with_remote_eligible(),
50 }
51 }
52}
53
54pub async fn execute(cmd: PluginsCommands, config: &CliConfig) -> Result<()> {
55 match cmd {
56 PluginsCommands::List(args) => {
57 render_result(&list::execute(&args, config));
58 Ok(())
59 },
60 PluginsCommands::Show(args) => {
61 let result = show::execute(&args, config).context("Failed to show extension")?;
62 render_result(&result);
63 Ok(())
64 },
65 PluginsCommands::Run(args) => run::execute(args, config).await,
66 PluginsCommands::Validate(args) => {
67 render_result(&validate::execute(&args, config));
68 Ok(())
69 },
70 PluginsCommands::Config(args) => {
71 let result =
72 config::execute(&args, config).context("Failed to get extension config")?;
73 render_result(&result);
74 Ok(())
75 },
76 PluginsCommands::Capabilities(args) => {
77 capabilities::execute(args, config);
78 Ok(())
79 },
80 PluginsCommands::Mcp(cmd) => mcp::execute_with_config(cmd, config).await,
81 }
82}