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 squash merge retired — stale records and
57 /// gone upstreams, never healthy seats — and remove only the
58 /// forge-confirmed ones, and only under --apply.
59 Prune {
60 /// The repository to read; any of its worktrees names it.
61 #[arg(long, default_value = ".")]
62 target: Utf8PathBuf,
63
64 /// Override the detected project path (owner/name) for the forge
65 /// confirmation.
66 #[arg(long)]
67 repo: Option<String>,
68
69 /// Override the detected forge: github or gitlab.
70 #[arg(long)]
71 forge: Option<String>,
72
73 /// Confirm each candidate against the forge's merged requests,
74 /// removing nothing.
75 #[arg(long)]
76 verify: bool,
77
78 /// Confirm each candidate, then remove the worktree before its
79 /// branch, and clear the stale records.
80 #[arg(long)]
81 apply: bool,
82
83 /// Print nothing when there is nothing to report, for the
84 /// post-merge hook.
85 #[arg(long, conflicts_with = "json")]
86 quiet: bool,
87
88 /// Emit one JSON object on stdout instead of the human report.
89 #[arg(long)]
90 json: bool,
91 },
92}