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