Skip to main content

ralph/cli/task/args/
lifecycle.rs

1//! CLI arguments for task lifecycle commands.
2//!
3//! Responsibilities:
4//! - Define Args structs for show, ready, status, done, start, reject, and schedule commands.
5//!
6//! Not handled here:
7//! - Command execution (see status, show, start, and schedule handlers).
8//!
9//! Invariants/assumptions:
10//! - All types must be Clone where needed for clap.
11
12use clap::Args;
13
14use crate::cli::queue::QueueShowFormat;
15use crate::cli::task::args::types::TaskStatusArg;
16
17#[derive(Args)]
18#[command(
19    after_long_help = "Examples:\n ralph task show RQ-0001\n ralph task show RQ-0001 --format compact"
20)]
21pub struct TaskShowArgs {
22    /// Task ID to show.
23    #[arg(value_name = "TASK_ID")]
24    pub task_id: String,
25
26    /// Output format.
27    #[arg(long, value_enum, default_value_t = QueueShowFormat::Json)]
28    pub format: QueueShowFormat,
29}
30
31#[derive(Args)]
32pub struct TaskReadyArgs {
33    /// Optional note to append when marking ready.
34    #[arg(long)]
35    pub note: Option<String>,
36
37    /// Draft task ID to promote.
38    #[arg(value_name = "TASK_ID")]
39    pub task_id: String,
40}
41
42#[derive(Args)]
43pub struct TaskStatusArgs {
44    /// Optional note to append.
45    #[arg(long)]
46    pub note: Option<String>,
47
48    /// New status.
49    #[arg(value_enum)]
50    pub status: TaskStatusArg,
51
52    /// Task ID(s) to update.
53    #[arg(value_name = "TASK_ID...")]
54    pub task_ids: Vec<String>,
55
56    /// Filter tasks by tag for batch operation (alternative to explicit IDs).
57    #[arg(long, value_name = "TAG")]
58    pub tag_filter: Vec<String>,
59}
60
61#[derive(Args)]
62pub struct TaskDoneArgs {
63    /// Notes to append (repeatable).
64    #[arg(long)]
65    pub note: Vec<String>,
66
67    /// Task ID to complete.
68    #[arg(value_name = "TASK_ID")]
69    pub task_id: String,
70}
71
72#[derive(Args)]
73#[command(
74    about = "Mark a task as started (sets started_at and moves to doing)",
75    after_long_help = "Examples:\n ralph task start RQ-0001\n ralph task start --reset RQ-0001"
76)]
77pub struct TaskStartArgs {
78    /// Task ID to start.
79    #[arg(value_name = "TASK_ID")]
80    pub task_id: String,
81
82    /// Reset started_at even if already set.
83    #[arg(long)]
84    pub reset: bool,
85}
86
87#[derive(Args)]
88pub struct TaskRejectArgs {
89    /// Notes to append (repeatable).
90    #[arg(long)]
91    pub note: Vec<String>,
92
93    /// Task ID to reject.
94    #[arg(value_name = "TASK_ID")]
95    pub task_id: String,
96}
97
98#[derive(Args)]
99#[command(
100    after_long_help = "Examples:\n  ralph task schedule RQ-0001 '2026-02-01T09:00:00Z'\n  ralph task schedule RQ-0001 'tomorrow 9am'\n  ralph task schedule RQ-0001 'in 2 hours'\n  ralph task schedule RQ-0001 'next monday'\n  ralph task schedule RQ-0001 --clear"
101)]
102pub struct TaskScheduleArgs {
103    /// Task ID to schedule.
104    #[arg(value_name = "TASK_ID")]
105    pub task_id: String,
106
107    /// Timestamp or relative time expression (e.g., 'tomorrow 9am', 'in 2 hours').
108    #[arg(value_name = "WHEN")]
109    pub when: Option<String>,
110
111    /// Clear the scheduled start time.
112    #[arg(long, conflicts_with = "when")]
113    pub clear: bool,
114}