systemprompt-cli 0.20.0

Unified CLI for systemprompt.io AI governance: agent orchestration, MCP governance, analytics, profiles, cloud deploy, and self-hosted operations.
Documentation
//! Management of HTML templates and their content-type bindings.
//!
//! Dispatches the `web templates` subcommands ([`TemplatesCommands`]) to list,
//! show, create, edit, and delete templates in the web templates config.

pub mod create;
pub mod delete;
pub mod edit;
pub mod list;
pub mod selection;
pub mod show;

use anyhow::{Context, Result};
use clap::Subcommand;

use crate::CliConfig;
use crate::interactive::Prompter;
use crate::shared::render_result;

#[derive(Debug, Subcommand)]
pub enum TemplatesCommands {
    #[command(about = "List all templates")]
    List(list::ListArgs),

    #[command(about = "Show template details")]
    Show(show::ShowArgs),

    #[command(about = "Create a new template")]
    Create(create::CreateArgs),

    #[command(about = "Edit a template")]
    Edit(edit::EditArgs),

    #[command(about = "Delete a template")]
    Delete(delete::DeleteArgs),
}

pub fn execute(
    command: TemplatesCommands,
    prompter: &dyn Prompter,
    config: &CliConfig,
) -> Result<()> {
    match command {
        TemplatesCommands::List(args) => {
            let result = list::execute(args, config).context("Failed to list templates")?;
            render_result(&result, config);
            Ok(())
        },
        TemplatesCommands::Show(args) => {
            let result =
                show::execute(args, prompter, config).context("Failed to show template")?;
            render_result(&result, config);
            Ok(())
        },
        TemplatesCommands::Create(args) => {
            let result =
                create::execute(args, prompter, config).context("Failed to create template")?;
            render_result(&result, config);
            Ok(())
        },
        TemplatesCommands::Edit(args) => {
            let result =
                edit::execute(args, prompter, config).context("Failed to edit template")?;
            render_result(&result, config);
            Ok(())
        },
        TemplatesCommands::Delete(args) => {
            let result =
                delete::execute(args, prompter, config).context("Failed to delete template")?;
            render_result(&result, config);
            Ok(())
        },
    }
}