Skip to main content

systemprompt_cli/commands/web/templates/
mod.rs

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