Skip to main content

systemprompt_cli/commands/web/
mod.rs

1//! The `web` command group: configuration management for the static-site layer.
2//!
3//! Routes [`WebCommands`] to the content-type, template, asset, sitemap, and
4//! validation subcommands, each operating on the on-disk web content config.
5
6pub mod assets;
7pub mod content_types;
8pub mod paths;
9pub mod sitemap;
10pub mod templates;
11pub mod types;
12mod validate;
13
14use anyhow::Result;
15use clap::Subcommand;
16
17use crate::context::CommandContext;
18use crate::shared::{CommandOutput, render_result};
19
20#[derive(Debug, Subcommand)]
21pub enum WebCommands {
22    #[command(subcommand, about = "Manage content types")]
23    ContentTypes(content_types::ContentTypesCommands),
24
25    #[command(subcommand, about = "Manage templates")]
26    Templates(templates::TemplatesCommands),
27
28    #[command(subcommand, about = "List and inspect assets")]
29    Assets(assets::AssetsCommands),
30
31    #[command(subcommand, about = "Sitemap operations")]
32    Sitemap(sitemap::SitemapCommands),
33
34    #[command(about = "Validate web configuration")]
35    Validate(validate::ValidateArgs),
36}
37
38pub fn execute(command: WebCommands, ctx: &CommandContext) -> Result<()> {
39    let config = &ctx.cli;
40    match command {
41        WebCommands::ContentTypes(cmd) => content_types::execute(cmd, config),
42        WebCommands::Templates(cmd) => templates::execute(cmd, config),
43        WebCommands::Assets(cmd) => assets::execute(cmd, config),
44        WebCommands::Sitemap(cmd) => sitemap::execute(cmd, config),
45        WebCommands::Validate(args) => {
46            let output = validate::execute(&args, config)?;
47            let valid = output.valid;
48            let error_count = output.errors.len();
49            render_result(
50                &CommandOutput::card_value("Web Configuration Validation", &output),
51                config,
52            );
53            if !valid {
54                return Err(anyhow::anyhow!(
55                    "web configuration is invalid: {error_count} error(s), see report above",
56                ));
57            }
58            Ok(())
59        },
60    }
61}