Skip to main content

systemprompt_cli/commands/core/agents/
mod.rs

1pub mod types;
2
3mod list;
4mod show;
5mod sync;
6mod validate;
7
8use anyhow::{Context, Result};
9use clap::Subcommand;
10
11use crate::cli_settings::get_global_config;
12use crate::shared::render_result;
13use crate::CliConfig;
14
15#[derive(Debug, Subcommand)]
16pub enum AgentsCommands {
17    #[command(about = "List configured agents")]
18    List(list::ListArgs),
19
20    #[command(about = "Show agent details")]
21    Show(show::ShowArgs),
22
23    #[command(about = "Sync agents between disk and database")]
24    Sync(sync::SyncArgs),
25
26    #[command(about = "Validate agent configurations")]
27    Validate(validate::ValidateArgs),
28}
29
30pub async fn execute(command: AgentsCommands) -> Result<()> {
31    let config = get_global_config();
32    execute_with_config(command, &config).await
33}
34
35pub async fn execute_with_config(command: AgentsCommands, config: &CliConfig) -> Result<()> {
36    match command {
37        AgentsCommands::List(args) => {
38            let result = list::execute(args, config).context("Failed to list agents")?;
39            render_result(&result);
40            Ok(())
41        },
42        AgentsCommands::Show(args) => {
43            let result = show::execute(&args, config).context("Failed to show agent")?;
44            render_result(&result);
45            Ok(())
46        },
47        AgentsCommands::Sync(args) => {
48            let result = sync::execute(args, config)
49                .await
50                .context("Failed to sync agents")?;
51            render_result(&result);
52            Ok(())
53        },
54        AgentsCommands::Validate(args) => {
55            let result = validate::execute(&args, config).context("Failed to validate agents")?;
56            render_result(&result);
57            Ok(())
58        },
59    }
60}