release_kit/cli/reconcile.rs
1//! Arguments for `rk reconcile`.
2
3use camino::Utf8PathBuf;
4use clap::{Args, Subcommand, ValueEnum};
5
6/// Compute, show, and apply the plan that converges a target toward one release.
7#[derive(Debug, Args)]
8pub struct ReconcileArgs {
9 /// What to do with a plan.
10 #[command(subcommand)]
11 pub action: ReconcileAction,
12}
13
14/// The reconcile operations.
15#[derive(Debug, Subcommand)]
16#[allow(
17 clippy::large_enum_variant,
18 reason = "the plan arguments carry every landing flag and the other actions carry an id; one enum per verb is the clap shape every subcommand here follows"
19)]
20pub enum ReconcileAction {
21 /// Observe the target, resolve the release, compute the plan, store it, and print it; nothing is written into the target.
22 Plan(PlanArgs),
23 /// Render a stored plan, human or --json.
24 Show(ShowArgs),
25 /// Execute a stored plan: recompute its fingerprint, refuse on any difference, write, and journal.
26 Apply(ApplyArgs),
27 /// List the stored plans, oldest first.
28 List(ListArgs),
29}
30
31/// What a plan may read beyond the target and the bundle.
32#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
33pub enum Observe {
34 /// Read the trunk's tip at the origin remote, and stamp it.
35 Forge,
36}
37
38/// Arguments for `rk reconcile plan`.
39#[derive(Debug, Args)]
40pub struct PlanArgs {
41 /// The repository to plan for.
42 #[arg(long, default_value = ".")]
43 pub target: Utf8PathBuf,
44
45 /// The release to converge toward: `embedded` for this binary's own
46 /// bundle, offline; `latest` or an exact version through the crates
47 /// venue, which reaches the network and says so.
48 #[arg(long, default_value = "embedded", value_name = "SELECTOR")]
49 pub to: String,
50
51 /// Read the recorded release's bundle through the crates venue where
52 /// the cache does not hold it, so the baseline is bytes; without it a
53 /// missing baseline is reported as not observed.
54 #[arg(long)]
55 pub fetch: bool,
56
57 /// Opt into a read beyond the target: `forge` reads the trunk's tip
58 /// at the origin remote.
59 #[arg(long, value_enum, value_name = "WHAT")]
60 pub observe: Vec<Observe>,
61
62 /// Select an answer to a decision the plan names, as `<id>=<answer>`;
63 /// repeatable. A selected decision is a fingerprint input.
64 #[arg(long, value_name = "ID=ANSWER")]
65 pub decide: Vec<String>,
66
67 /// Override the configured payload binding.
68 #[arg(long)]
69 pub tech: Option<String>,
70
71 /// Override the configured forge.
72 #[arg(long)]
73 pub forge: Option<String>,
74
75 /// Override the configured project path.
76 #[arg(long)]
77 pub repo: Option<String>,
78
79 /// Answer the working-copy mode: worktree or branches.
80 #[arg(long)]
81 pub workflow: Option<String>,
82
83 /// Answer the release style: trunk or lines.
84 #[arg(long)]
85 pub style: Option<String>,
86
87 /// Answer the Nix opt-in: `on` or `off`.
88 #[arg(long)]
89 pub nix: Option<String>,
90
91 /// Emit the plan as one JSON object on stdout instead of the human report.
92 #[arg(long)]
93 pub json: bool,
94}
95
96/// Arguments for `rk reconcile show`.
97#[derive(Debug, Args)]
98pub struct ShowArgs {
99 /// The plan id `rk reconcile plan` printed.
100 pub plan_id: String,
101
102 /// Emit the stored plan as one JSON object on stdout instead of the human report.
103 #[arg(long)]
104 pub json: bool,
105}
106
107/// Arguments for `rk reconcile apply`.
108#[derive(Debug, Args)]
109pub struct ApplyArgs {
110 /// The plan id `rk reconcile plan` printed.
111 pub plan_id: String,
112
113 /// Emit the apply report as one JSON object on stdout instead of the human report.
114 #[arg(long)]
115 pub json: bool,
116}
117
118/// Arguments for `rk reconcile list`.
119#[derive(Debug, Args)]
120pub struct ListArgs {
121 /// Emit the listing as one JSON object on stdout instead of the human report.
122 #[arg(long)]
123 pub json: bool,
124}