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 = "dev", global = true)]
60 pub env: String,
61
62 #[arg(long = "locale", global = true)]
64 pub locale: Option<String>,
65
66 #[arg(long = "advanced", global = true)]
68 pub advanced: bool,
69
70 #[arg(long = "ui", global = true, default_value_t = true)]
73 pub ui: bool,
74
75 #[arg(long = "no-ui", global = true)]
77 pub no_ui: bool,
78
79 #[arg(long = "non-interactive", global = true)]
81 pub non_interactive: bool,
82
83 #[command(subcommand)]
84 pub command: Option<Command>,
85}
86
87#[derive(Subcommand, Debug)]
88pub enum Command {
89 Doctor(DoctorArgs),
91 #[command(subcommand)]
93 Bundle(Box<BundleCommand>),
94}
95
96#[derive(Args, Debug, Clone)]
97pub struct DoctorArgs {
98 #[arg(value_name = "BUNDLE")]
100 pub bundle: PathBuf,
101 #[arg(long = "json")]
103 pub json: bool,
104 #[arg(long = "strict")]
106 pub strict: bool,
107 #[arg(long = "fix-hints")]
109 pub fix_hints: bool,
110 #[arg(long = "show-info")]
112 pub show_info: bool,
113 #[arg(long = "stage", value_enum)]
115 pub stage: Option<DoctorStageArg>,
116}
117
118#[derive(clap::ValueEnum, Debug, Clone, Copy, PartialEq, Eq)]
119pub enum DoctorStageArg {
120 Setup,
121 Cache,
122 Locks,
123 Answers,
124 Runtime,
125 Routes,
126}
127
128#[derive(Subcommand, Debug, Clone)]
129pub enum BundleCommand {
130 Init(BundleInitArgs),
132 Add(BundleAddArgs),
134 Setup(BundleSetupArgs),
136 Update(BundleSetupArgs),
138 Remove(BundleRemoveArgs),
140 Build(BundleBuildArgs),
142 List(BundleListArgs),
144 Status(BundleStatusArgs),
146}
147
148#[derive(Args, Debug, Clone)]
149pub struct BundleInitArgs {
150 #[arg(value_name = "PATH")]
152 pub path: Option<PathBuf>,
153 #[arg(long = "name", short = 'n')]
155 pub name: Option<String>,
156}
157
158#[derive(Args, Debug, Clone)]
159pub struct BundleAddArgs {
160 #[arg(value_name = "PACK_REF")]
162 pub pack_ref: String,
163 #[arg(long = "bundle", short = 'b')]
165 pub bundle: Option<PathBuf>,
166 #[arg(long = "tenant", short = 't', default_value = "demo")]
168 pub tenant: String,
169 #[arg(long = "team")]
171 pub team: Option<String>,
172 #[arg(long = "env", short = 'e', default_value = "dev")]
174 pub env: String,
175 #[arg(long = "dry-run")]
177 pub dry_run: bool,
178}
179
180#[derive(Args, Debug, Clone)]
181pub struct BundleSetupArgs {
182 #[arg(value_name = "PROVIDER_ID")]
184 pub provider_id: Option<String>,
185 #[arg(long = "bundle", short = 'b')]
187 pub bundle: Option<PathBuf>,
188 #[arg(long = "answers", short = 'a')]
190 pub answers: Option<PathBuf>,
191 #[arg(long = "key", value_name = "KEY")]
193 pub key: Option<String>,
194 #[arg(long = "tenant", short = 't', default_value = "demo")]
196 pub tenant: String,
197 #[arg(long = "team")]
199 pub team: Option<String>,
200 #[arg(long = "env", short = 'e', default_value = "dev")]
202 pub env: String,
203 #[arg(long = "domain", short = 'd', default_value = "all")]
205 pub domain: String,
206 #[arg(long = "parallel", default_value = "1")]
208 pub parallel: usize,
209 #[arg(long = "backup")]
211 pub backup: bool,
212 #[arg(long = "skip-secrets-init")]
214 pub skip_secrets_init: bool,
215 #[arg(long = "best-effort")]
217 pub best_effort: bool,
218 #[arg(skip)]
220 pub non_interactive: bool,
221 #[arg(long = "dry-run")]
223 pub dry_run: bool,
224 #[arg(long = "emit-answers")]
226 pub emit_answers: Option<PathBuf>,
227 #[arg(long = "advanced")]
229 pub advanced: bool,
230}
231
232#[derive(Args, Debug, Clone)]
233pub struct BundleRemoveArgs {
234 #[arg(value_name = "PROVIDER_ID")]
236 pub provider_id: String,
237 #[arg(long = "bundle", short = 'b')]
239 pub bundle: Option<PathBuf>,
240 #[arg(long = "tenant", short = 't', default_value = "demo")]
242 pub tenant: String,
243 #[arg(long = "team")]
245 pub team: Option<String>,
246 #[arg(long = "force", short = 'f')]
248 pub force: bool,
249}
250
251#[derive(Args, Debug, Clone)]
252pub struct BundleBuildArgs {
253 #[arg(long = "bundle", short = 'b')]
255 pub bundle: Option<PathBuf>,
256 #[arg(long = "out", short = 'o')]
258 pub out: PathBuf,
259 #[arg(long = "tenant", short = 't')]
261 pub tenant: Option<String>,
262 #[arg(long = "team")]
264 pub team: Option<String>,
265 #[arg(long = "only-used-providers")]
267 pub only_used_providers: bool,
268 #[arg(long = "doctor")]
270 pub doctor: bool,
271 #[arg(long = "skip-doctor")]
273 pub skip_doctor: bool,
274}
275
276#[derive(Args, Debug, Clone)]
277pub struct BundleListArgs {
278 #[arg(long = "bundle", short = 'b')]
280 pub bundle: Option<PathBuf>,
281 #[arg(long = "domain", short = 'd', default_value = "messaging")]
283 pub domain: String,
284 #[arg(long = "pack", short = 'p')]
286 pub pack: Option<String>,
287 #[arg(long = "format", default_value = "text")]
289 pub format: String,
290}
291
292#[derive(Args, Debug, Clone)]
293pub struct BundleStatusArgs {
294 #[arg(long = "bundle", short = 'b')]
296 pub bundle: Option<PathBuf>,
297 #[arg(long = "format", default_value = "text")]
299 pub format: String,
300}