Skip to main content

systemprompt_cli/commands/infrastructure/
mod.rs

1//! `infra` command group: services, database, jobs, and logs administration.
2//!
3//! Routes [`InfraCommands`] to the per-domain subcommand modules. On a
4//! `--database-url` invocation only the db and logs subtrees are served; the
5//! rest require a full profile context.
6//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10pub mod db;
11pub mod jobs;
12pub mod logs;
13pub mod services;
14
15use anyhow::Result;
16use clap::Subcommand;
17
18use crate::context::CommandContext;
19
20#[derive(Debug, Subcommand)]
21pub enum InfraCommands {
22    #[command(
23        subcommand,
24        about = "Service lifecycle management (start, stop, status)"
25    )]
26    Services(services::ServicesCommands),
27
28    #[command(subcommand, about = "Database operations and administration")]
29    Db(db::DbCommands),
30
31    #[command(subcommand, about = "Background jobs and scheduling")]
32    Jobs(jobs::JobsCommands),
33
34    #[command(subcommand, about = "Log streaming and tracing")]
35    Logs(logs::LogsCommands),
36}
37
38pub async fn execute(cmd: InfraCommands, ctx: &CommandContext) -> Result<()> {
39    if ctx.is_database_scoped() && !matches!(cmd, InfraCommands::Db(_) | InfraCommands::Logs(_)) {
40        return Err(crate::shared::database_scoped_command_error());
41    }
42
43    match cmd {
44        InfraCommands::Services(cmd) => services::execute(cmd, ctx).await,
45        InfraCommands::Db(cmd) => db::execute(cmd, ctx).await,
46        InfraCommands::Jobs(cmd) => jobs::execute(cmd, ctx).await,
47        InfraCommands::Logs(cmd) => logs::execute(cmd, ctx).await,
48    }
49}