spec_driven_docs/cli/self_depend.rs
1//! `self-depend` subcommand: parse-shape.
2//!
3//! Holds the clap derive structs only. No I/O, no business logic.
4
5use camino::Utf8PathBuf;
6use clap::{Subcommand, ValueEnum};
7
8use crate::self_depend::manager::Manager;
9use crate::self_depend::venue::Venue;
10
11/// Wire this tool as a consumer's dependency and keep its pin fresh.
12#[derive(Debug, clap::Args)]
13pub struct SelfDependArgs {
14 /// The verb to run.
15 #[command(subcommand)]
16 pub command: SelfDependCommand,
17}
18
19/// Every verb `sdd self-depend` offers.
20#[derive(Debug, Subcommand)]
21pub enum SelfDependCommand {
22 /// Report what a target carries, offline: each manager's pin, the shell-entry line, and any leftover.
23 Status(StatusArgs),
24 /// Serve the fragments for one manager and venue pair and the shell-entry line; seed the manager file where the target has none.
25 Add(AddArgs),
26 /// Move the pin to the latest release through the wired manager; the flake pair moves both files or neither.
27 Sync(SyncArgs),
28 /// Remove what a predecessor bump mechanism left, and name what a line scan must not touch.
29 Clean(CleanArgs),
30}
31
32/// Report what a target carries.
33#[derive(Debug, clap::Args)]
34pub struct StatusArgs {
35 /// The project to read; absolute, or the working directory.
36 #[arg(long, default_value = ".")]
37 pub target: Utf8PathBuf,
38
39 /// Report one manager's entry alone; every manager by default, absent ones included.
40 #[arg(long, value_enum)]
41 pub manager: Option<Manager>,
42
43 /// Print one JSON object instead of text.
44 #[arg(long)]
45 pub json: bool,
46}
47
48/// Serve the fragments for one pair.
49#[derive(Debug, clap::Args)]
50pub struct AddArgs {
51 /// The project to wire; absolute, or the working directory.
52 #[arg(long, default_value = ".")]
53 pub target: Utf8PathBuf,
54
55 /// The release tag to pin: v0.2.16, 0.2.16, or the release URL; this binary's version by default.
56 #[arg(long)]
57 pub tag: Option<String>,
58
59 /// Record that every host installs sdd itself, at this release or newer, instead of pinning it in a manager file.
60 #[arg(long, conflicts_with_all = ["tag", "manager", "venue"])]
61 pub host: bool,
62
63 /// The target's tool manager; required when the target carries several, the flake when it carries none.
64 #[arg(long, value_enum)]
65 pub manager: Option<Manager>,
66
67 /// Where this tool is fetched from; the first venue the manager renders a fragment for by default.
68 #[arg(long, value_enum)]
69 pub venue: Option<Venue>,
70
71 /// Write the seed files; without it the fragments are printed and nothing is written.
72 #[arg(long)]
73 pub apply: bool,
74
75 /// Print one JSON object instead of text.
76 #[arg(long)]
77 pub json: bool,
78}
79
80/// Who is calling the sync.
81#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
82pub enum Caller {
83 /// The shell-entry line on directory entry: gated by the stamp, silent, exit 0.
84 Envrc,
85 /// A person or an agent at a prompt: every outcome reported, the exit-code matrix.
86 Operator,
87}
88
89/// Move the pin.
90#[derive(Debug, clap::Args)]
91pub struct SyncArgs {
92 /// The project to sync; absolute, or the working directory.
93 #[arg(long, default_value = ".")]
94 pub target: Utf8PathBuf,
95
96 /// The release tag to pin, in either direction, making no network request; the latest release by default.
97 #[arg(long)]
98 pub tag: Option<String>,
99
100 /// The manager whose pin moves; the one manager naming this tool by default.
101 #[arg(long, value_enum)]
102 pub manager: Option<Manager>,
103
104 /// Who is calling: envrc stays silent and exits 0 on every outcome, operator reports and fails loudly.
105 #[arg(long, value_enum, default_value_t = Caller::Envrc)]
106 pub caller: Caller,
107
108 /// Rewrite the pin and refresh the lock; without it the bump is reported and nothing runs.
109 #[arg(long)]
110 pub apply: bool,
111
112 /// Print one JSON object instead of text.
113 #[arg(long)]
114 pub json: bool,
115}
116
117/// Remove what a predecessor left.
118#[derive(Debug, clap::Args)]
119pub struct CleanArgs {
120 /// The project to clean; absolute, or the working directory.
121 #[arg(long, default_value = ".")]
122 pub target: Utf8PathBuf,
123
124 /// One extra file to remove, relative to the target, for a predecessor the catalog does not know; repeatable.
125 #[arg(long)]
126 pub also: Vec<Utf8PathBuf>,
127
128 /// Remove the files; without it every leftover is listed.
129 #[arg(long)]
130 pub apply: bool,
131
132 /// Print one JSON object instead of text.
133 #[arg(long)]
134 pub json: bool,
135}