Skip to main content

release_kit/cli/
stage.rs

1//! Arguments for `rk stage`.
2
3use camino::Utf8PathBuf;
4use clap::{Args, Subcommand};
5
6/// Write the candidate this binary would land in a target into a
7/// disposable stage, beside the knowledge that explains it.
8///
9/// Reads the target and writes nothing inside it. The stage holds every
10/// proposed destination under `artifacts/`, the changelog, guidance,
11/// method, bindings, runbooks, forge notes, and setup skill under
12/// `reference/`, and one explanatory `stage.json`. Production landing
13/// never reads a stage; `rk stage clean <path>` removes one.
14#[derive(Debug, Args)]
15pub struct StageArgs {
16    /// The one companion: remove a stage.
17    #[command(subcommand)]
18    pub action: Option<StageAction>,
19
20    /// The technology whose candidate is staged; one of the bindings.
21    #[arg(long)]
22    pub tech: Option<String>,
23
24    /// The repository the candidate is computed for; read, never written.
25    #[arg(long, default_value = ".")]
26    pub target: Utf8PathBuf,
27
28    /// The forge whose files are staged: github or gitlab. Defaults to
29    /// detection from the target's git remote.
30    #[arg(long)]
31    pub forge: Option<String>,
32
33    /// The project path on the forge, substituted into the rendered files.
34    /// Defaults to detection from the target's git remote.
35    #[arg(long)]
36    pub repo: Option<String>,
37
38    /// The working-copy mode the candidate renders under: worktree or
39    /// branches.
40    #[arg(long)]
41    pub workflow: Option<String>,
42
43    /// The release style the candidate renders under: trunk or lines.
44    #[arg(long)]
45    pub style: Option<String>,
46
47    /// Stage the Nix capability too.
48    #[arg(long)]
49    pub nix: bool,
50
51    /// The exact directory to stage into; it must be absent or empty.
52    /// Without it, a target and version directory below `RK_STAGE_ROOT`,
53    /// else below the private state root.
54    #[arg(long)]
55    pub output: Option<Utf8PathBuf>,
56
57    /// Emit one JSON object on stdout instead of the human report.
58    #[arg(long)]
59    pub json: bool,
60}
61
62/// The stage subcommands.
63#[derive(Debug, Subcommand)]
64pub enum StageAction {
65    /// Remove exactly one stage directory, which must name itself in its
66    /// own stage.json.
67    Clean {
68        /// The stage directory, as `rk stage` printed it. No glob, no
69        /// parent, no link.
70        path: Utf8PathBuf,
71        /// Emit one JSON object on stdout instead of the human report.
72        #[arg(long)]
73        json: bool,
74    },
75}