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