1use std::path::PathBuf;
4
5use clap::{Args, Parser, Subcommand};
6
7#[derive(Parser, Debug)]
8#[command(name = "greentic-setup")]
9#[command(version)]
10#[command(about = "Greentic bundle setup CLI")]
11#[command(after_help = r#"EXAMPLES:
12 Interactive wizard:
13 greentic-setup ./my-bundle
14
15 Preview without executing:
16 greentic-setup --dry-run ./my-bundle
17
18 Generate answers template:
19 greentic-setup --dry-run --emit-answers answers.json ./my-bundle
20
21 Apply answers file:
22 greentic-setup --answers answers.json ./my-bundle.gtbundle
23
24 Advanced (bundle subcommands):
25 greentic-setup bundle init ./my-bundle
26 greentic-setup bundle add pack.gtpack --bundle ./my-bundle
27 greentic-setup bundle status --bundle ./my-bundle
28"#)]
29pub struct Cli {
30 #[arg(value_name = "BUNDLE")]
32 pub bundle: Option<PathBuf>,
33
34 #[arg(long = "dry-run", global = true)]
36 pub dry_run: bool,
37
38 #[arg(long = "emit-answers", value_name = "FILE", global = true)]
40 pub emit_answers: Option<PathBuf>,
41
42 #[arg(long = "answers", short = 'a', value_name = "FILE", global = true)]
44 pub answers: Option<PathBuf>,
45
46 #[arg(long = "key", value_name = "KEY", global = true)]
48 pub key: Option<String>,
49
50 #[arg(long = "tenant", short = 't', default_value = "demo", global = true)]
52 pub tenant: String,
53
54 #[arg(long = "team", global = true)]
56 pub team: Option<String>,
57
58 #[arg(long = "env", short = 'e', default_value = "local", global = true)]
61 pub env: String,
62
63 #[arg(long = "locale", global = true)]
65 pub locale: Option<String>,
66
67 #[arg(long = "advanced", global = true)]
69 pub advanced: bool,
70
71 #[arg(long = "ui", global = true, default_value_t = true)]
74 pub ui: bool,
75
76 #[arg(long = "no-ui", global = true)]
78 pub no_ui: bool,
79
80 #[arg(long = "non-interactive", global = true)]
82 pub non_interactive: bool,
83
84 #[command(subcommand)]
85 pub command: Option<Command>,
86}
87
88#[derive(Subcommand, Debug)]
89pub enum Command {
90 Doctor(DoctorArgs),
92 #[command(subcommand)]
94 Bundle(Box<BundleCommand>),
95}
96
97#[derive(Args, Debug, Clone)]
98pub struct DoctorArgs {
99 #[arg(value_name = "BUNDLE")]
101 pub bundle: PathBuf,
102 #[arg(long = "json")]
104 pub json: bool,
105 #[arg(long = "strict")]
107 pub strict: bool,
108 #[arg(long = "fix-hints")]
110 pub fix_hints: bool,
111 #[arg(long = "show-info")]
113 pub show_info: bool,
114 #[arg(long = "stage", value_enum)]
116 pub stage: Option<DoctorStageArg>,
117}
118
119#[derive(clap::ValueEnum, Debug, Clone, Copy, PartialEq, Eq)]
120pub enum DoctorStageArg {
121 Setup,
122 Cache,
123 Locks,
124 Answers,
125 Runtime,
126 Routes,
127}
128
129#[derive(Subcommand, Debug, Clone)]
130pub enum BundleCommand {
131 Init(BundleInitArgs),
133 Add(BundleAddArgs),
135 Setup(BundleSetupArgs),
137 Update(BundleSetupArgs),
139 Remove(BundleRemoveArgs),
141 Build(BundleBuildArgs),
143 List(BundleListArgs),
145 Status(BundleStatusArgs),
147}
148
149#[derive(Args, Debug, Clone)]
150pub struct BundleInitArgs {
151 #[arg(value_name = "PATH")]
153 pub path: Option<PathBuf>,
154 #[arg(long = "name", short = 'n')]
156 pub name: Option<String>,
157}
158
159#[derive(Args, Debug, Clone)]
160pub struct BundleAddArgs {
161 #[arg(value_name = "PACK_REF")]
163 pub pack_ref: String,
164 #[arg(long = "bundle", short = 'b')]
166 pub bundle: Option<PathBuf>,
167 #[arg(long = "tenant", short = 't', default_value = "demo")]
169 pub tenant: String,
170 #[arg(long = "team")]
172 pub team: Option<String>,
173 #[arg(long = "env", short = 'e', default_value = "local")]
176 pub env: String,
177 #[arg(long = "dry-run")]
179 pub dry_run: bool,
180}
181
182#[derive(Args, Debug, Clone)]
183pub struct BundleSetupArgs {
184 #[arg(value_name = "PROVIDER_ID")]
186 pub provider_id: Option<String>,
187 #[arg(long = "bundle", short = 'b')]
189 pub bundle: Option<PathBuf>,
190 #[arg(long = "answers", short = 'a')]
192 pub answers: Option<PathBuf>,
193 #[arg(long = "key", value_name = "KEY")]
195 pub key: Option<String>,
196 #[arg(long = "tenant", short = 't', default_value = "demo")]
198 pub tenant: String,
199 #[arg(long = "team")]
201 pub team: Option<String>,
202 #[arg(long = "env", short = 'e', default_value = "local")]
205 pub env: String,
206 #[arg(long = "domain", short = 'd', default_value = "all")]
208 pub domain: String,
209 #[arg(long = "parallel", default_value = "1")]
211 pub parallel: usize,
212 #[arg(long = "backup")]
214 pub backup: bool,
215 #[arg(long = "skip-secrets-init")]
217 pub skip_secrets_init: bool,
218 #[arg(long = "best-effort")]
220 pub best_effort: bool,
221 #[arg(skip)]
223 pub non_interactive: bool,
224 #[arg(long = "dry-run")]
226 pub dry_run: bool,
227 #[arg(long = "emit-answers")]
229 pub emit_answers: Option<PathBuf>,
230 #[arg(long = "advanced")]
232 pub advanced: bool,
233}
234
235#[derive(Args, Debug, Clone)]
236pub struct BundleRemoveArgs {
237 #[arg(value_name = "PROVIDER_ID")]
239 pub provider_id: String,
240 #[arg(long = "bundle", short = 'b')]
242 pub bundle: Option<PathBuf>,
243 #[arg(long = "tenant", short = 't', default_value = "demo")]
245 pub tenant: String,
246 #[arg(long = "team")]
248 pub team: Option<String>,
249 #[arg(long = "force", short = 'f')]
251 pub force: bool,
252}
253
254#[derive(Args, Debug, Clone)]
255pub struct BundleBuildArgs {
256 #[arg(long = "bundle", short = 'b')]
258 pub bundle: Option<PathBuf>,
259 #[arg(long = "out", short = 'o')]
261 pub out: PathBuf,
262 #[arg(long = "tenant", short = 't')]
264 pub tenant: Option<String>,
265 #[arg(long = "team")]
267 pub team: Option<String>,
268 #[arg(long = "only-used-providers")]
270 pub only_used_providers: bool,
271 #[arg(long = "doctor")]
273 pub doctor: bool,
274 #[arg(long = "skip-doctor")]
276 pub skip_doctor: bool,
277}
278
279#[derive(Args, Debug, Clone)]
280pub struct BundleListArgs {
281 #[arg(long = "bundle", short = 'b')]
283 pub bundle: Option<PathBuf>,
284 #[arg(long = "domain", short = 'd', default_value = "messaging")]
286 pub domain: String,
287 #[arg(long = "pack", short = 'p')]
289 pub pack: Option<String>,
290 #[arg(long = "format", default_value = "text")]
292 pub format: String,
293}
294
295#[derive(Args, Debug, Clone)]
296pub struct BundleStatusArgs {
297 #[arg(long = "bundle", short = 'b')]
299 pub bundle: Option<PathBuf>,
300 #[arg(long = "format", default_value = "text")]
302 pub format: String,
303}