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; required on github, 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    /// Run one step by name, for recovery and rerun.
67    Step {
68        /// The step, from `rk setup --list`.
69        name: String,
70        /// The repository to set up.
71        #[arg(long)]
72        target: Utf8PathBuf,
73        /// Override the detected project path (owner/name).
74        #[arg(long)]
75        repo: Option<String>,
76        /// Override the detected forge: github or gitlab.
77        #[arg(long)]
78        forge: Option<String>,
79        /// The check the gate must pass; required on github, refused on gitlab.
80        #[arg(long)]
81        required_check: Option<String>,
82        /// Run the step; without it the step is previewed and nothing runs.
83        #[arg(long)]
84        apply: bool,
85        /// Emit NDJSON events on stdout instead of the human report.
86        #[arg(long)]
87        json: bool,
88    },
89    /// Print one embedded setup script, for audit.
90    Script {
91        /// The step whose script to print.
92        name: String,
93        /// Which forge's tree to read; defaults to github.
94        #[arg(long)]
95        forge: Option<String>,
96    },
97}