Skip to main content

systemprompt_cli/commands/admin/config/
mod.rs

1//! `admin config` command tree: inspect and edit profile/service configuration.
2//!
3//! [`ConfigCommands`] dispatches to the show, list, and validate handlers plus
4//! the rate-limit, server, runtime, security, paths, and provider sub-trees.
5//! Each sub-module owns its clap surface and renders results through
6//! [`crate::shared::render_result`].
7
8pub mod catalog;
9pub mod config_section;
10pub mod gateway;
11pub mod governance;
12pub mod list;
13pub mod paths;
14pub mod profile_io;
15pub mod provider;
16pub mod rate_limit_types;
17pub mod rate_limits;
18pub mod reconcile;
19pub mod runtime;
20pub mod secret;
21pub mod security;
22pub mod server;
23pub mod show;
24pub mod types;
25pub mod validate;
26
27use anyhow::{Result, bail};
28use clap::Subcommand;
29
30use crate::context::CommandContext;
31use crate::shared::render_result;
32
33#[derive(Debug, Subcommand)]
34pub enum ConfigCommands {
35    #[command(about = "Show configuration overview")]
36    Show,
37
38    #[command(about = "List all configuration files")]
39    List(list::ListArgs),
40
41    #[command(about = "Validate configuration files")]
42    Validate(validate::ValidateArgs),
43
44    #[command(subcommand, about = "Rate limit configuration")]
45    RateLimits(rate_limits::RateLimitsCommands),
46
47    #[command(subcommand, about = "Server configuration")]
48    Server(server::ServerCommands),
49
50    #[command(subcommand, about = "Runtime configuration")]
51    Runtime(runtime::RuntimeCommands),
52
53    #[command(subcommand, about = "Security configuration")]
54    Security(security::SecurityCommands),
55
56    #[command(subcommand, about = "Paths configuration")]
57    Paths(paths::PathsCommands),
58
59    #[command(subcommand, about = "AI provider configuration")]
60    Provider(provider::ProviderCommands),
61
62    #[command(subcommand, about = "Gateway configuration (routes, default provider)")]
63    Gateway(gateway::GatewayCommands),
64
65    #[command(subcommand, about = "Governance authorization hook configuration")]
66    Governance(governance::GovernanceCommands),
67
68    #[command(
69        subcommand,
70        about = "Provider registry (profile.providers: providers, models)"
71    )]
72    Catalog(catalog::CatalogCommands),
73
74    #[command(subcommand, about = "Profile secrets")]
75    Secret(secret::SecretCommands),
76}
77
78pub async fn execute(command: ConfigCommands, ctx: &CommandContext) -> Result<()> {
79    match command {
80        ConfigCommands::Show => {
81            let result = show::execute(&ctx.cli)?;
82            render_result(&result, &ctx.cli);
83            Ok(())
84        },
85        ConfigCommands::List(args) => {
86            let result = list::execute(args, &ctx.cli);
87            render_result(&result, &ctx.cli);
88            Ok(())
89        },
90        ConfigCommands::Validate(args) => {
91            let (result, valid) = validate::execute(&args, &ctx.cli)?;
92            render_result(&result, &ctx.cli);
93            if !valid {
94                bail!("Config validation failed");
95            }
96            Ok(())
97        },
98        ConfigCommands::RateLimits(cmd) => rate_limits::execute(cmd, &ctx.cli),
99        ConfigCommands::Server(ref cmd) => server::execute(cmd, &ctx.cli),
100        ConfigCommands::Runtime(cmd) => runtime::execute(cmd, &ctx.cli),
101        ConfigCommands::Security(ref cmd) => security::execute(cmd, &ctx.cli),
102        ConfigCommands::Paths(cmd) => paths::execute(cmd, &ctx.cli),
103        ConfigCommands::Provider(cmd) => provider::execute(cmd, &ctx.cli),
104        ConfigCommands::Gateway(ref cmd) => gateway::execute(cmd, &ctx.cli).await,
105        ConfigCommands::Governance(ref cmd) => governance::execute(cmd, &ctx.cli),
106        ConfigCommands::Catalog(ref cmd) => catalog::execute(cmd, &ctx.cli).await,
107        ConfigCommands::Secret(ref cmd) => secret::execute(cmd, &ctx.cli),
108    }
109}