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