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