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