release_kit/cli/self_depend.rs
1//! Arguments for `rk self-depend`.
2
3use camino::Utf8PathBuf;
4use clap::{Args, Subcommand, ValueEnum};
5
6use crate::self_depend::manager::Manager;
7
8/// Wire release-kit as a consumer's dependency and keep its pin fresh.
9#[derive(Debug, Args)]
10pub struct SelfDependArgs {
11 /// What to do with the pin wiring.
12 #[command(subcommand)]
13 pub action: SelfDependAction,
14}
15
16/// The self-depend operations.
17#[derive(Debug, Subcommand)]
18pub enum SelfDependAction {
19 /// Report what a target carries, offline: each manager's pin, the .envrc line, and any leftover.
20 Status(StatusArgs),
21 /// Serve the flake fragments and the .envrc line; seed both files where the target has none.
22 Add(AddArgs),
23 /// Remove what a predecessor bump mechanism left, and name what a line scan must not touch.
24 Clean(CleanArgs),
25 /// Move the pin to the latest release, lock it, and prove it builds; both files or neither.
26 Sync(SyncArgs),
27}
28
29/// Arguments for `rk self-depend status`.
30#[derive(Debug, Args)]
31pub struct StatusArgs {
32 /// The project to read.
33 #[arg(long, default_value = ".")]
34 pub target: Utf8PathBuf,
35
36 /// Report one manager's entry alone; every manager by default, absent ones included.
37 #[arg(long, value_enum)]
38 pub manager: Option<Manager>,
39
40 /// Emit one JSON object on stdout instead of the human report.
41 #[arg(long)]
42 pub json: bool,
43}
44
45/// Arguments for `rk self-depend add`.
46#[derive(Debug, Args)]
47pub struct AddArgs {
48 /// The project to wire.
49 #[arg(long, default_value = ".")]
50 pub target: Utf8PathBuf,
51
52 /// The release tag to pin: v0.2.16, 0.2.16, or the release URL; this binary's version by default.
53 #[arg(long)]
54 pub tag: Option<String>,
55
56 /// Write the seed files; without it the fragments are printed and nothing is written.
57 #[arg(long)]
58 pub apply: bool,
59
60 /// Emit one JSON object on stdout instead of the human report.
61 #[arg(long)]
62 pub json: bool,
63}
64
65/// Arguments for `rk self-depend clean`.
66#[derive(Debug, Args)]
67pub struct CleanArgs {
68 /// The project to clean.
69 #[arg(long, default_value = ".")]
70 pub target: Utf8PathBuf,
71
72 /// One extra file to remove, for a predecessor the catalog does not know; repeatable.
73 #[arg(long, value_name = "PATH")]
74 pub also: Vec<Utf8PathBuf>,
75
76 /// Remove the files and rewrite .envrc; without it every leftover is listed.
77 #[arg(long)]
78 pub apply: bool,
79
80 /// Emit one JSON object on stdout instead of the human report.
81 #[arg(long)]
82 pub json: bool,
83}
84
85/// Arguments for `rk self-depend sync`.
86#[derive(Debug, Args)]
87pub struct SyncArgs {
88 /// The project to sync.
89 #[arg(long, default_value = ".")]
90 pub target: Utf8PathBuf,
91
92 /// The release tag to pin, in either direction, making no network request; the latest release by default, forward only.
93 #[arg(long)]
94 pub tag: Option<String>,
95
96 /// Who is calling: envrc stays silent and exits 0 on every outcome, operator reports and fails loudly.
97 #[arg(long, value_enum, default_value_t = Caller::Envrc)]
98 pub caller: Caller,
99
100 /// Rewrite the pin, refresh the lock, and build; without it the bump is reported and nothing runs.
101 #[arg(long)]
102 pub apply: bool,
103
104 /// Emit one JSON object on stdout instead of the human report.
105 #[arg(long)]
106 pub json: bool,
107}
108
109/// Who invoked the sync. One flag decides four behaviors as a bundle: the
110/// daily stamp, silence on nothing to do, the exit code of a reported
111/// failure, and silence under lock contention.
112#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
113#[value(rename_all = "kebab-case")]
114pub enum Caller {
115 /// The `.envrc` line on directory entry: gated by the stamp, silent, exit 0.
116 Envrc,
117 /// A person or an agent at a prompt: every outcome reported, the exit-code matrix.
118 Operator,
119}