Skip to main content

release_kit/cli/
setup.rs

1//! Arguments for `rk setup`.
2
3use camino::Utf8PathBuf;
4use clap::{Args, Subcommand};
5
6/// Execute the repository-side setup against the detected forge.
7///
8/// Without a subcommand: preview every step, or run them in order under
9/// `--apply`; `--list` prints the ordered steps and what each proves.
10#[derive(Debug, Args)]
11pub struct SetupArgs {
12    /// The read-only companions: check, one step, one script.
13    #[command(subcommand)]
14    pub action: Option<SetupAction>,
15
16    /// The repository to set up.
17    #[arg(long)]
18    pub target: Option<Utf8PathBuf>,
19
20    /// Override the detected project path (owner/name).
21    #[arg(long)]
22    pub repo: Option<String>,
23
24    /// Override the detected forge: github or gitlab.
25    #[arg(long)]
26    pub forge: Option<String>,
27
28    /// The check the gate must pass; overrides `setup.required_check`, refused on gitlab.
29    #[arg(long)]
30    pub required_check: Option<String>,
31
32    /// Run the steps; without it every step is previewed and nothing runs.
33    #[arg(long)]
34    pub apply: bool,
35
36    /// List the ordered steps and what each proves, and run nothing.
37    #[arg(long)]
38    pub list: bool,
39
40    /// Emit NDJSON events on stdout instead of the human report.
41    #[arg(long)]
42    pub json: bool,
43}
44
45/// The setup subcommands.
46#[derive(Debug, Subcommand)]
47pub enum SetupAction {
48    /// Prove the desired state against the forge, mutating nothing.
49    Check {
50        /// The repository to check.
51        #[arg(long)]
52        target: Utf8PathBuf,
53        /// Override the detected project path (owner/name).
54        #[arg(long)]
55        repo: Option<String>,
56        /// Override the detected forge: github or gitlab.
57        #[arg(long)]
58        forge: Option<String>,
59        /// The check the gate must pass, verified where given.
60        #[arg(long)]
61        required_check: Option<String>,
62        /// Emit NDJSON events on stdout instead of the human report.
63        #[arg(long)]
64        json: bool,
65    },
66    /// Observe every step and, only where every applicable step holds,
67    /// commit the result to .release-kit/setup-proof.json.
68    Checkpoint {
69        /// The repository to check.
70        #[arg(long)]
71        target: Utf8PathBuf,
72        /// Override the detected project path (owner/name).
73        #[arg(long)]
74        repo: Option<String>,
75        /// Override the detected forge: github or gitlab.
76        #[arg(long)]
77        forge: Option<String>,
78        /// The check the gate must pass, verified where given.
79        #[arg(long)]
80        required_check: Option<String>,
81        /// Emit NDJSON events on stdout instead of the human report.
82        #[arg(long)]
83        json: bool,
84    },
85    /// Judge the committed setup proof against this target, offline: no
86    /// forge call and no credential.
87    Status {
88        /// The repository whose proof to read.
89        #[arg(long)]
90        target: Utf8PathBuf,
91        /// Override the detected project path (owner/name).
92        #[arg(long)]
93        repo: Option<String>,
94        /// Override the detected forge: github or gitlab.
95        #[arg(long)]
96        forge: Option<String>,
97        /// The check the gate must pass, as the checkpoint named it.
98        #[arg(long)]
99        required_check: Option<String>,
100        /// Emit one rk.setup-status/1 document instead of the human report.
101        #[arg(long)]
102        json: bool,
103    },
104    /// Run one step by name, for recovery and rerun.
105    Step {
106        /// The step, from `rk setup --list`.
107        name: String,
108        /// The repository to set up.
109        #[arg(long)]
110        target: Utf8PathBuf,
111        /// Override the detected project path (owner/name).
112        #[arg(long)]
113        repo: Option<String>,
114        /// Override the detected forge: github or gitlab.
115        #[arg(long)]
116        forge: Option<String>,
117        /// The check the gate must pass; overrides `setup.required_check`, refused on gitlab.
118        #[arg(long)]
119        required_check: Option<String>,
120        /// Run the step; without it the step is previewed and nothing runs.
121        #[arg(long)]
122        apply: bool,
123        /// Emit NDJSON events on stdout instead of the human report.
124        #[arg(long)]
125        json: bool,
126    },
127    /// Print one embedded setup script, for audit.
128    Script {
129        /// The step whose script to print.
130        name: String,
131        /// Which forge's tree to read; defaults to github.
132        #[arg(long)]
133        forge: Option<String>,
134    },
135}