Skip to main content

release_kit/cli/
upgrade.rs

1//! Arguments for `rk upgrade`.
2
3use camino::Utf8PathBuf;
4use clap::Args;
5
6use super::profile_flags::ProfileFlags;
7
8/// Take a landed target to this binary's projection.
9///
10/// Flags resolve over configuration, and recorded answers stand where
11/// both are silent. Preview by default; `--apply` replaces every recorded
12/// generated file, preserves every seeded and state file, and rewrites
13/// the receipt last.
14#[derive(Debug, Args)]
15pub struct UpgradeArgs {
16    /// The landed repository to upgrade.
17    #[arg(long, default_value = ".")]
18    pub target: Utf8PathBuf,
19
20    /// The project profile and the Git workflow, each flag overriding the
21    /// configured answer; the apply writes the answer back into the
22    /// config. Omitted, the config answers first and the record is the
23    /// fallback.
24    #[command(flatten)]
25    pub profile: ProfileFlags,
26
27    /// Change the recorded Nix request: `on` adds the capability's files
28    /// and records it; `off` drops them from the record while the files
29    /// stay on disk as the target's own, like any file this binary stops
30    /// shipping. Omitted, configuration precedes the recorded choice.
31    #[arg(long, alias = "nix", value_name = "on|off")]
32    pub nix_packaging: Option<String>,
33
34    /// Change the recorded reporting policy request: `on` lands
35    /// `SECURITY.md` and records it; `off` drops it from the record while
36    /// the file stays on disk as the target's own.
37    #[arg(long, value_name = "on|off")]
38    pub reporting_policy: Option<String>,
39
40    /// Change the recorded Scorecard request: `on` adds the workflow and
41    /// records it; `off` drops it from the record while the file stays on
42    /// disk as the target's own, like any file this binary stops shipping.
43    /// Omitted, configuration precedes the recorded choice.
44    #[arg(long, value_name = "on|off")]
45    pub scorecard: Option<String>,
46
47    /// Change the recorded code scanning provider: `codeql` or `semgrep`
48    /// lands that provider's workflow and records it; `off` drops it from
49    /// the record while the file stays on disk as the target's own. Omitted,
50    /// configuration precedes the recorded choice.
51    #[arg(long, value_name = "PROVIDER")]
52    pub code_scanning: Option<String>,
53
54    /// Land the answers a stage resolved, read from its receipt and
55    /// never its bytes; refuses a stage another binary wrote or one taken
56    /// for another target.
57    #[arg(long, value_name = "ROOT")]
58    pub stage: Option<Utf8PathBuf>,
59
60    /// Save a copy of this conflict, then replace it: an unattributed
61    /// file, or a recorded rendered file someone edited. Repeatable;
62    /// every conflict not named still refuses.
63    #[arg(long = "replace", value_name = "PATH")]
64    pub replace: Vec<String>,
65
66    /// Change the recorded workflow guards: `on` keeps or adds their
67    /// lines, glossary, and hooks, and `off` drops them. A record that
68    /// predates the capability carries a pending answer, which this
69    /// upgrade reports and answers `on` unless this flag says otherwise.
70    /// Omitted, configuration precedes the recorded choice.
71    #[arg(long, value_name = "on|off")]
72    pub workflow_guards: Option<String>,
73
74    /// Land the Git workflow and nothing of a release: a preset that sets
75    /// `profile.release.mode = "none"`, `git.integration = "local"`,
76    /// `git.checkout_mode = "linked-worktree"`, and
77    /// `capabilities.workflow_guards = true`, and records those four
78    /// answers alone. A flag that contradicts one of them refuses before
79    /// any write; a flag the preset does not set, such as `--merge-form`,
80    /// combines with it.
81    #[arg(long)]
82    pub workflow_only: bool,
83
84    /// Write the upgrade; without it every file's action is listed and
85    /// nothing is touched. `rk stage` is the full-byte comparison surface.
86    #[arg(long)]
87    pub apply: bool,
88
89    /// Emit one JSON object on stdout instead of the human report.
90    #[arg(long)]
91    pub json: bool,
92}