systemprompt_cli/commands/infrastructure/jobs/
mod.rs1pub mod types;
8
9mod cleanup_logs;
10mod cleanup_sessions;
11mod disable;
12mod enable;
13mod helpers;
14mod history;
15mod list;
16mod run;
17mod show;
18
19use anyhow::Result;
20use clap::Subcommand;
21
22use crate::context::CommandContext;
23use crate::shared::render_result;
24
25use systemprompt_generator as _;
26
27#[derive(Debug, Subcommand)]
28pub enum JobsCommands {
29 #[command(about = "List available jobs")]
30 List,
31
32 #[command(about = "Show detailed information about a job")]
33 Show(show::ShowArgs),
34
35 #[command(about = "Run a scheduled job manually")]
36 Run(run::RunArgs),
37
38 #[command(about = "View job execution history")]
39 History(history::HistoryArgs),
40
41 #[command(about = "Enable a job")]
42 Enable(enable::EnableArgs),
43
44 #[command(about = "Disable a job")]
45 Disable(disable::DisableArgs),
46
47 #[command(about = "Clean up inactive sessions")]
48 CleanupSessions(cleanup_sessions::CleanupSessionsArgs),
49
50 #[command(about = "Clean up old log entries")]
51 LogCleanup(cleanup_logs::LogCleanupArgs),
52
53 #[command(about = "Clean up inactive sessions (alias)", hide = true)]
54 SessionCleanup(cleanup_sessions::CleanupSessionsArgs),
55}
56
57pub async fn execute(cmd: JobsCommands, ctx: &CommandContext) -> Result<()> {
58 match cmd {
59 JobsCommands::List => {
60 render_result(&list::execute(), &ctx.cli);
61 Ok(())
62 },
63 JobsCommands::Show(args) => {
64 render_result(&show::execute(args).await?, &ctx.cli);
65 Ok(())
66 },
67 JobsCommands::Run(args) => {
68 render_result(&run::execute(args, ctx).await?, &ctx.cli);
69 Ok(())
70 },
71 JobsCommands::History(args) => {
72 render_result(&history::execute(args).await?, &ctx.cli);
73 Ok(())
74 },
75 JobsCommands::Enable(args) => {
76 render_result(&enable::execute(args).await?, &ctx.cli);
77 Ok(())
78 },
79 JobsCommands::Disable(args) => {
80 render_result(&disable::execute(args).await?, &ctx.cli);
81 Ok(())
82 },
83 JobsCommands::CleanupSessions(args) | JobsCommands::SessionCleanup(args) => {
84 render_result(&cleanup_sessions::execute(args).await?, &ctx.cli);
85 Ok(())
86 },
87 JobsCommands::LogCleanup(args) => {
88 render_result(&cleanup_logs::execute(args).await?, &ctx.cli);
89 Ok(())
90 },
91 }
92}