Skip to main content

systemprompt_cli/commands/core/playbooks/
mod.rs

1mod create;
2mod delete;
3mod edit;
4pub mod list;
5mod path_helpers;
6pub mod show;
7pub mod sync;
8pub mod types;
9
10use anyhow::{Context, Result};
11use clap::Subcommand;
12
13use crate::shared::render_result;
14use crate::CliConfig;
15
16#[derive(Debug, Subcommand)]
17pub enum PlaybooksCommands {
18    #[command(about = "List playbooks")]
19    List(list::ListArgs),
20
21    #[command(about = "Show full playbook content")]
22    Show(show::ShowArgs),
23
24    #[command(about = "Create new playbook")]
25    Create(create::CreateArgs),
26
27    #[command(about = "Edit playbook configuration")]
28    Edit(edit::EditArgs),
29
30    #[command(about = "Delete a playbook")]
31    Delete(delete::DeleteArgs),
32
33    #[command(about = "Sync playbooks between disk and database")]
34    Sync(sync::SyncArgs),
35}
36
37pub async fn execute(cmd: PlaybooksCommands, config: &CliConfig) -> Result<()> {
38    match cmd {
39        PlaybooksCommands::List(args) => {
40            let result = list::execute(args).context("Failed to list playbooks")?;
41            render_result(&result);
42            Ok(())
43        },
44        PlaybooksCommands::Show(args) => {
45            let result = show::execute(&args).context("Failed to show playbook")?;
46            render_result(&result);
47            Ok(())
48        },
49        PlaybooksCommands::Create(args) => {
50            let result = create::execute(args, config)
51                .await
52                .context("Failed to create playbook")?;
53            render_result(&result);
54            Ok(())
55        },
56        PlaybooksCommands::Edit(args) => {
57            let result = edit::execute(&args, config).context("Failed to edit playbook")?;
58            render_result(&result);
59            Ok(())
60        },
61        PlaybooksCommands::Delete(args) => {
62            let result = delete::execute(args, config).context("Failed to delete playbook")?;
63            render_result(&result);
64            Ok(())
65        },
66        PlaybooksCommands::Sync(args) => {
67            let result = sync::execute(args, config)
68                .await
69                .context("Failed to sync playbooks")?;
70            render_result(&result);
71            Ok(())
72        },
73    }
74}