Skip to main content

systemprompt_cli/commands/admin/config/
mod.rs

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