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: Option<PathBuf>,
102 #[command(subcommand)]
103 pub command: Option<DoctorCommand>,
104 #[arg(long = "json")]
106 pub json: bool,
107 #[arg(long = "strict")]
109 pub strict: bool,
110 #[arg(long = "fix-hints")]
112 pub fix_hints: bool,
113 #[arg(long = "show-info")]
115 pub show_info: bool,
116 #[arg(long = "stage", value_enum)]
118 pub stage: Option<DoctorStageArg>,
119}
120
121#[derive(Subcommand, Debug, Clone)]
122pub enum DoctorCommand {
123 Provider(DoctorProviderArgs),
125}
126
127#[derive(Args, Debug, Clone)]
128pub struct DoctorProviderArgs {
129 #[arg(value_name = "PACK")]
131 pub pack: PathBuf,
132}
133
134#[derive(clap::ValueEnum, Debug, Clone, Copy, PartialEq, Eq)]
135pub enum DoctorStageArg {
136 Setup,
137 Cache,
138 Locks,
139 Answers,
140 Runtime,
141 Routes,
142}
143
144#[derive(Subcommand, Debug, Clone)]
145pub enum BundleCommand {
146 Init(BundleInitArgs),
148 Add(BundleAddArgs),
150 Setup(BundleSetupArgs),
152 Update(BundleSetupArgs),
154 SetupStatus(BundleSetupStatusArgs),
156 SetupNext(BundleSetupNextArgs),
158 SetupRetry(BundleSetupRetryArgs),
160 SetupReset(BundleSetupResetArgs),
162 SetupMigrate(BundleSetupMigrateArgs),
164 Remove(BundleRemoveArgs),
166 Build(BundleBuildArgs),
168 List(BundleListArgs),
170 Status(BundleStatusArgs),
172}
173
174#[derive(Args, Debug, Clone)]
175pub struct BundleInitArgs {
176 #[arg(value_name = "PATH")]
178 pub path: Option<PathBuf>,
179 #[arg(long = "name", short = 'n')]
181 pub name: Option<String>,
182}
183
184#[derive(Args, Debug, Clone)]
185pub struct BundleAddArgs {
186 #[arg(value_name = "PACK_REF")]
188 pub pack_ref: String,
189 #[arg(long = "bundle", short = 'b')]
191 pub bundle: Option<PathBuf>,
192 #[arg(long = "tenant", short = 't', default_value = "demo")]
194 pub tenant: String,
195 #[arg(long = "team")]
197 pub team: Option<String>,
198 #[arg(long = "env", short = 'e', default_value = "local")]
201 pub env: String,
202 #[arg(long = "dry-run")]
204 pub dry_run: bool,
205}
206
207#[derive(Args, Debug, Clone)]
208pub struct BundleSetupArgs {
209 #[arg(value_name = "PROVIDER_ID")]
211 pub provider_id: Option<String>,
212 #[arg(long = "bundle", short = 'b')]
214 pub bundle: Option<PathBuf>,
215 #[arg(long = "answers", short = 'a')]
217 pub answers: Option<PathBuf>,
218 #[arg(long = "key", value_name = "KEY")]
220 pub key: Option<String>,
221 #[arg(long = "tenant", short = 't', default_value = "demo")]
223 pub tenant: String,
224 #[arg(long = "team")]
226 pub team: Option<String>,
227 #[arg(long = "env", short = 'e', default_value = "local")]
230 pub env: String,
231 #[arg(long = "domain", short = 'd', default_value = "all")]
233 pub domain: String,
234 #[arg(long = "parallel", default_value = "1")]
236 pub parallel: usize,
237 #[arg(long = "backup")]
239 pub backup: bool,
240 #[arg(long = "skip-secrets-init")]
242 pub skip_secrets_init: bool,
243 #[arg(long = "best-effort")]
245 pub best_effort: bool,
246 #[arg(skip)]
248 pub non_interactive: bool,
249 #[arg(long = "dry-run")]
251 pub dry_run: bool,
252 #[arg(long = "emit-answers")]
254 pub emit_answers: Option<PathBuf>,
255 #[arg(long = "advanced")]
257 pub advanced: bool,
258}
259
260#[derive(Args, Debug, Clone)]
261pub struct BundleSetupStatusArgs {
262 #[arg(value_name = "PROVIDER_ID")]
264 pub provider_id: String,
265 #[arg(long = "bundle", short = 'b')]
267 pub bundle: Option<PathBuf>,
268 #[arg(long = "tenant", short = 't', default_value = "demo")]
270 pub tenant: String,
271 #[arg(long = "team")]
273 pub team: Option<String>,
274 #[arg(long = "env", short = 'e', default_value = "dev")]
276 pub env: String,
277 #[arg(long = "format", default_value = "text")]
279 pub format: String,
280}
281
282#[derive(Args, Debug, Clone)]
283pub struct BundleSetupNextArgs {
284 #[arg(value_name = "PROVIDER_ID")]
286 pub provider_id: String,
287 #[arg(long = "bundle", short = 'b')]
289 pub bundle: Option<PathBuf>,
290 #[arg(long = "tenant", short = 't', default_value = "demo")]
292 pub tenant: String,
293 #[arg(long = "team")]
295 pub team: Option<String>,
296 #[arg(long = "env", short = 'e', default_value = "dev")]
298 pub env: String,
299 #[arg(long = "format", default_value = "text")]
301 pub format: String,
302 #[arg(long = "dry-run")]
304 pub dry_run: bool,
305}
306
307#[derive(Args, Debug, Clone)]
308pub struct BundleSetupRetryArgs {
309 #[arg(value_name = "PROVIDER_ID")]
311 pub provider_id: String,
312 #[arg(long = "bundle", short = 'b')]
314 pub bundle: Option<PathBuf>,
315 #[arg(long = "tenant", short = 't', default_value = "demo")]
317 pub tenant: String,
318 #[arg(long = "team")]
320 pub team: Option<String>,
321 #[arg(long = "env", short = 'e', default_value = "dev")]
323 pub env: String,
324 #[arg(long = "step")]
326 pub step: Option<String>,
327 #[arg(long = "json")]
329 pub json: bool,
330}
331
332#[derive(Args, Debug, Clone)]
333pub struct BundleSetupResetArgs {
334 #[arg(value_name = "PROVIDER_ID")]
336 pub provider_id: String,
337 #[arg(long = "bundle", short = 'b')]
339 pub bundle: Option<PathBuf>,
340 #[arg(long = "tenant", short = 't', default_value = "demo")]
342 pub tenant: String,
343 #[arg(long = "team")]
345 pub team: Option<String>,
346 #[arg(long = "yes")]
348 pub yes: bool,
349 #[arg(long = "json")]
351 pub json: bool,
352}
353
354#[derive(Args, Debug, Clone)]
355pub struct BundleSetupMigrateArgs {
356 #[arg(value_name = "PROVIDER_ID")]
358 pub provider_id: String,
359 #[arg(long = "bundle", short = 'b')]
361 pub bundle: Option<PathBuf>,
362 #[arg(long = "tenant", short = 't', default_value = "demo")]
364 pub tenant: String,
365 #[arg(long = "team")]
367 pub team: Option<String>,
368 #[arg(long = "env", short = 'e', default_value = "dev")]
370 pub env: String,
371 #[arg(long = "json")]
373 pub json: bool,
374}
375
376#[derive(Args, Debug, Clone)]
377pub struct BundleRemoveArgs {
378 #[arg(value_name = "PROVIDER_ID")]
380 pub provider_id: String,
381 #[arg(long = "bundle", short = 'b')]
383 pub bundle: Option<PathBuf>,
384 #[arg(long = "tenant", short = 't', default_value = "demo")]
386 pub tenant: String,
387 #[arg(long = "team")]
389 pub team: Option<String>,
390 #[arg(long = "force", short = 'f')]
392 pub force: bool,
393}
394
395#[derive(Args, Debug, Clone)]
396pub struct BundleBuildArgs {
397 #[arg(long = "bundle", short = 'b')]
399 pub bundle: Option<PathBuf>,
400 #[arg(long = "out", short = 'o')]
402 pub out: PathBuf,
403 #[arg(long = "tenant", short = 't')]
405 pub tenant: Option<String>,
406 #[arg(long = "team")]
408 pub team: Option<String>,
409 #[arg(long = "only-used-providers")]
411 pub only_used_providers: bool,
412 #[arg(long = "doctor")]
414 pub doctor: bool,
415 #[arg(long = "skip-doctor")]
417 pub skip_doctor: bool,
418}
419
420#[derive(Args, Debug, Clone)]
421pub struct BundleListArgs {
422 #[arg(long = "bundle", short = 'b')]
424 pub bundle: Option<PathBuf>,
425 #[arg(long = "domain", short = 'd', default_value = "messaging")]
427 pub domain: String,
428 #[arg(long = "pack", short = 'p')]
430 pub pack: Option<String>,
431 #[arg(long = "format", default_value = "text")]
433 pub format: String,
434}
435
436#[derive(Args, Debug, Clone)]
437pub struct BundleStatusArgs {
438 #[arg(long = "bundle", short = 'b')]
440 pub bundle: Option<PathBuf>,
441 #[arg(long = "format", default_value = "text")]
443 pub format: String,
444}