systemprompt_cli/commands/web/templates/
mod.rs1mod create;
2mod delete;
3mod edit;
4mod list;
5mod show;
6
7use anyhow::{Context, Result};
8use clap::Subcommand;
9
10use crate::shared::render_result;
11use crate::CliConfig;
12
13#[derive(Debug, Subcommand)]
14pub enum TemplatesCommands {
15 #[command(about = "List all templates")]
16 List(list::ListArgs),
17
18 #[command(about = "Show template details")]
19 Show(show::ShowArgs),
20
21 #[command(about = "Create a new template")]
22 Create(create::CreateArgs),
23
24 #[command(about = "Edit a template")]
25 Edit(edit::EditArgs),
26
27 #[command(about = "Delete a template")]
28 Delete(delete::DeleteArgs),
29}
30
31pub fn execute(command: TemplatesCommands, config: &CliConfig) -> Result<()> {
32 match command {
33 TemplatesCommands::List(args) => {
34 let result = list::execute(args, config).context("Failed to list templates")?;
35 render_result(&result);
36 Ok(())
37 },
38 TemplatesCommands::Show(args) => {
39 let result = show::execute(args, config).context("Failed to show template")?;
40 render_result(&result);
41 Ok(())
42 },
43 TemplatesCommands::Create(args) => {
44 let result = create::execute(args, config).context("Failed to create template")?;
45 render_result(&result);
46 Ok(())
47 },
48 TemplatesCommands::Edit(args) => {
49 let result = edit::execute(args, config).context("Failed to edit template")?;
50 render_result(&result);
51 Ok(())
52 },
53 TemplatesCommands::Delete(args) => {
54 let result = delete::execute(args, config).context("Failed to delete template")?;
55 render_result(&result);
56 Ok(())
57 },
58 }
59}