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
6pub mod types;
7
8mod list;
9mod validate;
10
11use anyhow::{Context, Result};
12use clap::Subcommand;
13
14use crate::context::CommandContext;
15use crate::shared::render_result;
16
17#[derive(Debug, Clone, Copy, Subcommand)]
18pub enum HooksCommands {
19    #[command(about = "List hooks across all plugins")]
20    List(list::ListArgs),
21
22    #[command(about = "Validate all hook definitions")]
23    Validate(validate::ValidateArgs),
24}
25
26pub fn execute(command: HooksCommands, ctx: &CommandContext) -> Result<()> {
27    match command {
28        HooksCommands::List(args) => {
29            let result = list::execute(args, &ctx.cli).context("Failed to list hooks")?;
30            render_result(&result, &ctx.cli);
31            Ok(())
32        },
33        HooksCommands::Validate(args) => {
34            let result = validate::execute(args, &ctx.cli).context("Failed to validate hooks")?;
35            render_result(&result, &ctx.cli);
36            Ok(())
37        },
38    }
39}