Skip to main content

systemprompt_cli/commands/core/hooks/
mod.rs

1//! `core hooks` command group: list and validate plugin hook definitions.
2//!
3//! Dispatches the [`HooksCommands`] subcommands (list, validate) that enumerate
4//! hooks across installed plugins and check their definitions.
5//!
6//! Copyright (c) systemprompt.io — Business Source License 1.1.
7//! See <https://systemprompt.io> for licensing details.
8
9pub mod types;
10
11mod list;
12mod validate;
13
14use anyhow::{Context, Result};
15use clap::Subcommand;
16
17use crate::context::CommandContext;
18use crate::shared::render_result;
19
20#[derive(Debug, Clone, Copy, Subcommand)]
21pub enum HooksCommands {
22    #[command(about = "List hooks across all plugins")]
23    List(list::ListArgs),
24
25    #[command(about = "Validate all hook definitions")]
26    Validate(validate::ValidateArgs),
27}
28
29pub fn execute(command: HooksCommands, ctx: &CommandContext) -> Result<()> {
30    match command {
31        HooksCommands::List(args) => {
32            let result = list::execute(args, &ctx.cli).context("Failed to list hooks")?;
33            render_result(&result, &ctx.cli);
34            Ok(())
35        },
36        HooksCommands::Validate(args) => {
37            let result = validate::execute(args, &ctx.cli).context("Failed to validate hooks")?;
38            render_result(&result, &ctx.cli);
39            Ok(())
40        },
41    }
42}