Skip to main content

systemprompt_cli/commands/admin/config/
mod.rs

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