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 config_section;
9pub mod list;
10pub mod paths;
11pub mod provider;
12pub mod rate_limit_types;
13pub mod rate_limits;
14pub mod runtime;
15pub mod security;
16pub mod server;
17pub mod show;
18pub mod types;
19pub mod validate;
20
21use anyhow::Result;
22use clap::Subcommand;
23
24use crate::CliConfig;
25use crate::cli_settings::get_global_config;
26use crate::shared::render_result;
27
28#[derive(Debug, Subcommand)]
29pub enum ConfigCommands {
30    #[command(about = "Show configuration overview")]
31    Show,
32
33    #[command(about = "List all configuration files")]
34    List(list::ListArgs),
35
36    #[command(about = "Validate configuration files")]
37    Validate(validate::ValidateArgs),
38
39    #[command(subcommand, about = "Rate limit configuration")]
40    RateLimits(rate_limits::RateLimitsCommands),
41
42    #[command(subcommand, about = "Server configuration")]
43    Server(server::ServerCommands),
44
45    #[command(subcommand, about = "Runtime configuration")]
46    Runtime(runtime::RuntimeCommands),
47
48    #[command(subcommand, about = "Security configuration")]
49    Security(security::SecurityCommands),
50
51    #[command(subcommand, about = "Paths configuration")]
52    Paths(paths::PathsCommands),
53
54    #[command(subcommand, about = "AI provider configuration")]
55    Provider(provider::ProviderCommands),
56}
57
58pub fn execute(command: ConfigCommands, config: &CliConfig) -> Result<()> {
59    match command {
60        ConfigCommands::Show => {
61            let result = show::execute(config)?;
62            render_result(&result);
63            Ok(())
64        },
65        ConfigCommands::List(args) => {
66            let result = list::execute(args, config);
67            render_result(&result);
68            Ok(())
69        },
70        ConfigCommands::Validate(args) => {
71            let result = validate::execute(&args, config)?;
72            render_result(&result);
73            Ok(())
74        },
75        ConfigCommands::RateLimits(cmd) => rate_limits::execute(cmd, config),
76        ConfigCommands::Server(ref cmd) => server::execute(cmd, config),
77        ConfigCommands::Runtime(cmd) => runtime::execute(cmd, config),
78        ConfigCommands::Security(ref cmd) => security::execute(cmd, config),
79        ConfigCommands::Paths(cmd) => paths::execute(cmd, config),
80        ConfigCommands::Provider(cmd) => provider::execute(cmd, config),
81    }
82}
83
84pub fn execute_default() -> Result<()> {
85    let config = get_global_config();
86    let result = show::execute(&config)?;
87    render_result(&result);
88    Ok(())
89}