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//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11pub mod catalog;
12pub mod config_section;
13pub mod gateway;
14pub mod governance;
15pub mod list;
16pub mod paths;
17pub mod profile_io;
18pub mod provider;
19pub mod rate_limit_types;
20pub mod rate_limits;
21pub mod reconcile;
22pub mod runtime;
23pub mod secret;
24pub mod secret_check;
25pub mod security;
26pub mod server;
27pub mod services;
28pub mod services_io;
29pub mod show;
30pub mod types;
31pub mod validate;
32
33use anyhow::{Result, bail};
34use clap::Subcommand;
35
36use crate::context::CommandContext;
37use crate::shared::render_result;
38
39#[derive(Debug, Subcommand)]
40pub enum ConfigCommands {
41    #[command(about = "Show configuration overview")]
42    Show,
43
44    #[command(about = "List all configuration files")]
45    List(list::ListArgs),
46
47    #[command(about = "Validate configuration files")]
48    Validate(validate::ValidateArgs),
49
50    #[command(subcommand, about = "Rate limit configuration")]
51    RateLimits(rate_limits::RateLimitsCommands),
52
53    #[command(subcommand, about = "Server configuration")]
54    Server(server::ServerCommands),
55
56    #[command(subcommand, about = "Runtime configuration")]
57    Runtime(runtime::RuntimeCommands),
58
59    #[command(subcommand, about = "Security configuration")]
60    Security(security::SecurityCommands),
61
62    #[command(subcommand, about = "Services configuration")]
63    Services(services::ServicesCommands),
64
65    #[command(subcommand, about = "Paths configuration")]
66    Paths(paths::PathsCommands),
67
68    #[command(subcommand, about = "AI provider configuration")]
69    Provider(provider::ProviderCommands),
70
71    #[command(subcommand, about = "Gateway configuration (routes, default provider)")]
72    Gateway(gateway::GatewayCommands),
73
74    #[command(subcommand, about = "Governance authorization hook configuration")]
75    Governance(governance::GovernanceCommands),
76
77    #[command(
78        subcommand,
79        about = "Provider registry (services/ai/providers.yaml: providers, models)"
80    )]
81    Catalog(catalog::CatalogCommands),
82
83    #[command(subcommand, about = "Profile secrets")]
84    Secret(secret::SecretCommands),
85}
86
87pub async fn execute(command: ConfigCommands, ctx: &CommandContext) -> Result<()> {
88    match command {
89        ConfigCommands::Show => {
90            let result = show::execute(&ctx.cli)?;
91            render_result(&result, &ctx.cli);
92            Ok(())
93        },
94        ConfigCommands::List(args) => {
95            let result = list::execute(args, &ctx.cli);
96            render_result(&result, &ctx.cli);
97            Ok(())
98        },
99        ConfigCommands::Validate(args) => {
100            let (result, valid) = validate::execute(&args, &ctx.cli)?;
101            render_result(&result, &ctx.cli);
102            if !valid {
103                bail!("Config validation failed");
104            }
105            Ok(())
106        },
107        ConfigCommands::RateLimits(cmd) => rate_limits::execute(cmd, ctx.prompter(), &ctx.cli),
108        ConfigCommands::Server(ref cmd) => server::execute(cmd, &ctx.cli),
109        ConfigCommands::Runtime(cmd) => runtime::execute(cmd, &ctx.cli),
110        ConfigCommands::Security(ref cmd) => security::execute(cmd, &ctx.cli),
111        ConfigCommands::Services(ref cmd) => services::execute(cmd, &ctx.cli),
112        ConfigCommands::Paths(cmd) => paths::execute(cmd, &ctx.cli),
113        ConfigCommands::Provider(cmd) => provider::execute(cmd, &ctx.cli),
114        ConfigCommands::Gateway(ref cmd) => gateway::execute(cmd, &ctx.cli).await,
115        ConfigCommands::Governance(ref cmd) => governance::execute(cmd, &ctx.cli),
116        ConfigCommands::Catalog(ref cmd) => catalog::execute(cmd, &ctx.cli).await,
117        ConfigCommands::Secret(ref cmd) => secret::execute(cmd, &ctx.cli).await,
118    }
119}