release_kit/cli/worktree.rs
1//! Arguments for `rk worktree`.
2
3use camino::Utf8PathBuf;
4use clap::{Args, Subcommand};
5
6/// Inspect, create, and prune the linked worktrees beside a checkout.
7#[derive(Debug, Args)]
8pub struct WorktreeArgs {
9 /// What to do with the worktrees.
10 #[command(subcommand)]
11 pub action: WorktreeAction,
12}
13
14/// The worktree verbs, mode-free by design: they behave identically under
15/// the worktree and branches workflows.
16#[derive(Debug, Subcommand)]
17pub enum WorktreeAction {
18 /// Report every worktree of the repository, offline.
19 List {
20 /// The repository to read; any of its worktrees names it.
21 #[arg(long, default_value = ".")]
22 target: Utf8PathBuf,
23
24 /// Emit one JSON object on stdout instead of the human report.
25 #[arg(long)]
26 json: bool,
27 },
28
29 /// Create or adopt one branch's worktree at the sibling path
30 /// `../<project>@<flattened branch>`; preview by default.
31 Add {
32 /// The branch to seat: an existing local branch is adopted, a
33 /// lone matching remote tip becomes a tracking branch, and
34 /// anything else is created from --base or the refreshed trunk.
35 branch: String,
36
37 /// The repository to act on; any of its worktrees names it.
38 #[arg(long, default_value = ".")]
39 target: Utf8PathBuf,
40
41 /// The commit-ish a new branch starts from; required for a
42 /// release/* line, which is cut from a tag and never the tip.
43 #[arg(long)]
44 base: Option<String>,
45
46 /// Create the worktree; without it the intent is reported and
47 /// nothing is touched.
48 #[arg(long)]
49 apply: bool,
50
51 /// Emit one JSON object on stdout instead of the human report.
52 #[arg(long)]
53 json: bool,
54 },
55
56 /// Report the worktrees a merge retired — stale records, gone
57 /// upstreams, and branches a local integration or the trunk already
58 /// carries, never healthy seats — and remove only the proven ones, and
59 /// only under --apply.
60 Prune {
61 /// The repository to read; any of its worktrees names it.
62 #[arg(long, default_value = ".")]
63 target: Utf8PathBuf,
64
65 /// Override the detected project path (owner/name) for the forge
66 /// confirmation.
67 #[arg(long)]
68 repo: Option<String>,
69
70 /// Override the detected forge: github or gitlab.
71 #[arg(long)]
72 forge: Option<String>,
73
74 /// Confirm each candidate against the forge's merged requests,
75 /// removing nothing.
76 #[arg(long)]
77 verify: bool,
78
79 /// Confirm each candidate, then remove the worktree before its
80 /// branch, and clear the stale records.
81 #[arg(long)]
82 apply: bool,
83
84 /// Print nothing when there is nothing to report, for the
85 /// post-merge hook.
86 #[arg(long, conflicts_with = "json")]
87 quiet: bool,
88
89 /// Emit one JSON object on stdout instead of the human report.
90 #[arg(long)]
91 json: bool,
92 },
93}