Skip to main content

ralph/cli/task/args/
relations.rs

1//! CLI arguments for task relationship commands.
2//!
3//! Responsibilities:
4//! - Define Args structs for clone, split, children, parent, relate, blocks, and mark-duplicate commands.
5//! - Define TaskRelationFormat enum for output formatting.
6//!
7//! Not handled here:
8//! - Command execution (see clone, split, children, parent, and relations handlers).
9//!
10//! Invariants/assumptions:
11//! - All types must be Clone where needed for clap.
12
13use clap::Args;
14
15use crate::cli::task::args::types::TaskStatusArg;
16
17/// Output format for task hierarchy commands (children, parent).
18#[derive(clap::ValueEnum, Clone, Copy, Debug, Eq, PartialEq)]
19#[clap(rename_all = "snake_case")]
20pub enum TaskRelationFormat {
21    Compact,
22    Long,
23    Json,
24}
25
26#[derive(Args)]
27pub struct TaskCloneArgs {
28    /// Source task ID to clone.
29    #[arg(value_name = "TASK_ID")]
30    pub task_id: String,
31
32    /// Status for the cloned task (default: draft).
33    #[arg(long, value_enum)]
34    pub status: Option<TaskStatusArg>,
35
36    /// Prefix to add to the cloned task title.
37    #[arg(long)]
38    pub title_prefix: Option<String>,
39
40    /// Preview the clone without modifying the queue.
41    #[arg(long)]
42    pub dry_run: bool,
43}
44
45#[derive(Args)]
46#[command(
47    after_long_help = "Examples:\n  ralph task split RQ-0001\n  ralph task split --number 3 RQ-0001\n  ralph task split --status todo --number 2 RQ-0001\n  ralph task split --distribute-plan RQ-0001"
48)]
49pub struct TaskSplitArgs {
50    /// Task ID to split.
51    #[arg(value_name = "TASK_ID")]
52    pub task_id: String,
53
54    /// Number of child tasks to create (default: 2, minimum: 2).
55    #[arg(short = 'n', long, default_value = "2")]
56    pub number: usize,
57
58    /// Status for child tasks (default: draft).
59    #[arg(long, value_enum)]
60    pub status: Option<TaskStatusArg>,
61
62    /// Prefix to add to child task titles.
63    #[arg(long)]
64    pub title_prefix: Option<String>,
65
66    /// Distribute plan items across child tasks.
67    #[arg(long)]
68    pub distribute_plan: bool,
69
70    /// Preview the split without modifying the queue.
71    #[arg(long)]
72    pub dry_run: bool,
73}
74
75#[derive(Args)]
76#[command(
77    about = "List child tasks (parent_id == TASK_ID)",
78    after_long_help = "Examples:\n ralph task children RQ-0001\n ralph task children RQ-0001 --recursive\n ralph task children RQ-0001 --include-done\n ralph task children RQ-0001 --format json"
79)]
80pub struct TaskChildrenArgs {
81    #[arg(value_name = "TASK_ID")]
82    pub task_id: String,
83
84    #[arg(long)]
85    pub include_done: bool,
86
87    #[arg(long)]
88    pub recursive: bool,
89
90    #[arg(long, value_enum, default_value_t = TaskRelationFormat::Compact)]
91    pub format: TaskRelationFormat,
92}
93
94#[derive(Args)]
95#[command(
96    about = "Show a task's parent (parent_id)",
97    after_long_help = "Examples:\n ralph task parent RQ-0002\n ralph task parent RQ-0002 --include-done\n ralph task parent RQ-0002 --format json"
98)]
99pub struct TaskParentArgs {
100    #[arg(value_name = "TASK_ID")]
101    pub task_id: String,
102
103    #[arg(long)]
104    pub include_done: bool,
105
106    #[arg(long, value_enum, default_value_t = TaskRelationFormat::Compact)]
107    pub format: TaskRelationFormat,
108}
109
110#[derive(Args)]
111#[command(
112    after_long_help = "Examples:\n  ralph task relate RQ-0001 blocks RQ-0002\n  ralph task relate RQ-0001 relates_to RQ-0003\n  ralph task relate RQ-0001 duplicates RQ-0004"
113)]
114pub struct TaskRelateArgs {
115    /// Source task ID.
116    #[arg(value_name = "TASK_ID")]
117    pub task_id: String,
118
119    /// Relationship type (blocks, relates_to, duplicates).
120    #[arg(value_name = "RELATION")]
121    pub relation: String,
122
123    /// Target task ID.
124    #[arg(value_name = "OTHER_TASK_ID")]
125    pub other_task_id: String,
126}
127
128#[derive(Args)]
129#[command(
130    after_long_help = "Examples:\n  ralph task blocks RQ-0001 RQ-0002\n  ralph task blocks RQ-0001 RQ-0002 RQ-0003"
131)]
132pub struct TaskBlocksArgs {
133    /// Task that does the blocking.
134    #[arg(value_name = "TASK_ID")]
135    pub task_id: String,
136
137    /// Task(s) being blocked.
138    #[arg(value_name = "BLOCKED_TASK_ID...")]
139    pub blocked_task_ids: Vec<String>,
140}
141
142#[derive(Args)]
143#[command(after_long_help = "Examples:\n  ralph task mark-duplicate RQ-0001 RQ-0002")]
144pub struct TaskMarkDuplicateArgs {
145    /// Task to mark as duplicate.
146    #[arg(value_name = "TASK_ID")]
147    pub task_id: String,
148
149    /// Original task this duplicates.
150    #[arg(value_name = "ORIGINAL_TASK_ID")]
151    pub original_task_id: String,
152}