Skip to main content

systemprompt_cli/commands/infrastructure/
mod.rs

1pub mod db;
2pub mod jobs;
3pub mod logs;
4pub mod services;
5
6use anyhow::Result;
7use clap::Subcommand;
8use systemprompt_runtime::DatabaseContext;
9
10use crate::CliConfig;
11
12#[derive(Debug, Subcommand)]
13pub enum InfraCommands {
14    #[command(
15        subcommand,
16        about = "Service lifecycle management (start, stop, status)"
17    )]
18    Services(services::ServicesCommands),
19
20    #[command(subcommand, about = "Database operations and administration")]
21    Db(db::DbCommands),
22
23    #[command(subcommand, about = "Background jobs and scheduling")]
24    Jobs(jobs::JobsCommands),
25
26    #[command(subcommand, about = "Log streaming and tracing")]
27    Logs(logs::LogsCommands),
28}
29
30pub async fn execute(cmd: InfraCommands, config: &CliConfig) -> Result<()> {
31    match cmd {
32        InfraCommands::Services(cmd) => services::execute(cmd, config).await,
33        InfraCommands::Db(cmd) => db::execute(cmd, config).await,
34        InfraCommands::Jobs(cmd) => jobs::execute(cmd, config).await,
35        InfraCommands::Logs(cmd) => logs::execute(cmd, config).await,
36    }
37}
38
39pub async fn execute_with_db(
40    cmd: InfraCommands,
41    db_ctx: &DatabaseContext,
42    config: &CliConfig,
43) -> Result<()> {
44    match cmd {
45        InfraCommands::Db(cmd) => db::execute_with_db(cmd, db_ctx, config).await,
46        InfraCommands::Logs(cmd) => logs::execute_with_db(cmd, db_ctx, config).await,
47        _ => anyhow::bail!("This command requires full profile context"),
48    }
49}