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