Skip to main content

systemprompt_cli/commands/core/plugins/
mod.rs

1//! `plugins` CLI command group: list, show, validate, and generate plugins.
2//!
3//! [`PluginsCommands`] enumerates the subcommands; [`execute`] dispatches each
4//! to its submodule and renders the result. Output payload types live in
5//! [`types`].
6//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10pub mod types;
11
12pub mod generate;
13pub mod list;
14pub mod show;
15pub mod validate;
16
17use anyhow::{Context, Result};
18use clap::Subcommand;
19
20use crate::context::CommandContext;
21use crate::shared::render_result;
22
23#[derive(Debug, Subcommand)]
24pub enum PluginsCommands {
25    #[command(about = "List configured plugins")]
26    List(list::ListArgs),
27
28    #[command(about = "Show plugin details")]
29    Show(show::ShowArgs),
30
31    #[command(about = "Validate plugin configuration")]
32    Validate(validate::ValidateArgs),
33
34    #[command(about = "Generate Claude Code plugin output")]
35    Generate(generate::GenerateArgs),
36}
37
38pub fn execute(command: PluginsCommands, ctx: &CommandContext) -> Result<()> {
39    match command {
40        PluginsCommands::List(args) => {
41            let result = list::execute(args, &ctx.cli).context("Failed to list plugins")?;
42            render_result(&result, &ctx.cli);
43            Ok(())
44        },
45        PluginsCommands::Show(args) => {
46            let result = show::execute(&args, &ctx.cli).context("Failed to show plugin")?;
47            render_result(&result, &ctx.cli);
48            Ok(())
49        },
50        PluginsCommands::Validate(args) => {
51            let result = validate::execute(args, &ctx.cli).context("Failed to validate plugins")?;
52            render_result(&result, &ctx.cli);
53            Ok(())
54        },
55        PluginsCommands::Generate(args) => {
56            let result =
57                generate::execute(&args, &ctx.cli).context("Failed to generate plugins")?;
58            render_result(&result, &ctx.cli);
59            Ok(())
60        },
61    }
62}