systemprompt_cli/commands/infrastructure/
mod.rs1pub 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()
40 && !matches!(
41 cmd,
42 InfraCommands::Db(_)
43 | InfraCommands::Logs(_)
44 | InfraCommands::Jobs(
45 jobs::JobsCommands::List
46 | jobs::JobsCommands::Show(_)
47 | jobs::JobsCommands::History(_)
48 )
49 )
50 {
51 return Err(crate::shared::database_scoped_command_error());
52 }
53
54 match cmd {
55 InfraCommands::Services(cmd) => services::execute(cmd, ctx).await,
56 InfraCommands::Db(cmd) => db::execute(cmd, ctx).await,
57 InfraCommands::Jobs(cmd) => jobs::execute(cmd, ctx).await,
58 InfraCommands::Logs(cmd) => logs::execute(cmd, ctx).await,
59 }
60}