systemprompt-cli 0.1.22

systemprompt.io OS - CLI for agent orchestration, AI operations, and system management
Documentation
pub mod config_section;
pub mod list;
pub mod paths;
pub mod provider;
pub mod rate_limit_types;
pub mod rate_limits;
pub mod runtime;
pub mod security;
pub mod server;
pub mod show;
pub mod types;
pub mod validate;

use anyhow::Result;
use clap::Subcommand;

use crate::CliConfig;
use crate::cli_settings::get_global_config;
use crate::shared::render_result;

#[derive(Debug, Subcommand)]
pub enum ConfigCommands {
    #[command(about = "Show configuration overview")]
    Show,

    #[command(about = "List all configuration files")]
    List(list::ListArgs),

    #[command(about = "Validate configuration files")]
    Validate(validate::ValidateArgs),

    #[command(subcommand, about = "Rate limit configuration")]
    RateLimits(rate_limits::RateLimitsCommands),

    #[command(subcommand, about = "Server configuration")]
    Server(server::ServerCommands),

    #[command(subcommand, about = "Runtime configuration")]
    Runtime(runtime::RuntimeCommands),

    #[command(subcommand, about = "Security configuration")]
    Security(security::SecurityCommands),

    #[command(subcommand, about = "Paths configuration")]
    Paths(paths::PathsCommands),

    #[command(subcommand, about = "AI provider configuration")]
    Provider(provider::ProviderCommands),
}

pub fn execute(command: ConfigCommands, config: &CliConfig) -> Result<()> {
    match command {
        ConfigCommands::Show => {
            let result = show::execute(config)?;
            render_result(&result);
            Ok(())
        },
        ConfigCommands::List(args) => {
            let result = list::execute(args, config);
            render_result(&result);
            Ok(())
        },
        ConfigCommands::Validate(args) => {
            let result = validate::execute(&args, config)?;
            render_result(&result);
            Ok(())
        },
        ConfigCommands::RateLimits(cmd) => rate_limits::execute(cmd, config),
        ConfigCommands::Server(ref cmd) => server::execute(cmd, config),
        ConfigCommands::Runtime(cmd) => runtime::execute(cmd, config),
        ConfigCommands::Security(ref cmd) => security::execute(cmd, config),
        ConfigCommands::Paths(cmd) => paths::execute(cmd, config),
        ConfigCommands::Provider(cmd) => provider::execute(cmd, config),
    }
}

pub fn execute_default() -> Result<()> {
    let config = get_global_config();
    let result = show::execute(&config)?;
    render_result(&result);
    Ok(())
}