Skip to main content

greentic_dev/
cli.rs

1use std::{ffi::OsString, path::PathBuf};
2
3use crate::secrets_cli::SecretsCommand;
4use clap::{Arg, ArgAction, Args, CommandFactory, Parser, Subcommand};
5
6#[derive(Parser, Debug)]
7#[command(name = "greentic-dev")]
8#[command(version)]
9#[command(about = "cli.root.about")]
10pub struct Cli {
11    #[command(subcommand)]
12    pub command: Command,
13}
14
15pub fn localized_help_command(locale: &str) -> clap::Command {
16    let mut command = Cli::command()
17        .about(crate::i18n::t(locale, "cli.root.about"))
18        .disable_help_subcommand(true)
19        .disable_help_flag(true)
20        .disable_version_flag(true)
21        .arg(
22            Arg::new("help")
23                .short('h')
24                .long("help")
25                .action(ArgAction::Help)
26                .help(crate::i18n::t(locale, "cli.help.flag")),
27        )
28        .arg(
29            Arg::new("version")
30                .short('V')
31                .long("version")
32                .action(ArgAction::Version)
33                .help(crate::i18n::t(locale, "cli.version.flag")),
34        )
35        .arg(
36            Arg::new("locale")
37                .long("locale")
38                .global(true)
39                .value_name("LOCALE")
40                .help(crate::i18n::t(locale, "cli.option.locale")),
41        );
42
43    for (name, key) in [
44        ("flow", "cli.command.flow.about"),
45        ("pack", "cli.command.pack.about"),
46        ("component", "cli.command.component.about"),
47        ("bundle", "cli.command.bundle.about"),
48        ("runner", "cli.command.runner.about"),
49        ("config", "cli.command.config.about"),
50        ("coverage", "cli.command.coverage.about"),
51        ("security", "cli.command.security.about"),
52        ("mcp", "cli.command.mcp.about"),
53        ("gui", "cli.command.gui.about"),
54        ("secrets", "cli.command.secrets.about"),
55        ("tools", "cli.command.tools.about"),
56        ("install", "cli.command.install.about"),
57        ("release", "cli.command.release.about"),
58        ("cbor", "cli.command.cbor.about"),
59        ("wizard", "cli.command.wizard.about"),
60    ] {
61        command = command.mut_subcommand(name, |sub| sub.about(crate::i18n::t(locale, key)));
62    }
63
64    command = command.mut_subcommand("secrets", |sub| {
65        sub.about(crate::i18n::t(locale, "cli.command.secrets.about"))
66            .mut_subcommand("init", |sub| {
67                sub.about(crate::i18n::t(locale, "cli.command.secrets.init.about"))
68                    .mut_arg("pack", |arg| {
69                        arg.help(crate::i18n::t(locale, "cli.command.secrets.init.pack"))
70                    })
71                    .mut_arg("passthrough", |arg| {
72                        arg.help(crate::i18n::t(
73                            locale,
74                            "cli.command.secrets.init.passthrough",
75                        ))
76                    })
77            })
78    });
79    command = command
80        .mut_subcommand("config", |sub| {
81            sub.about(crate::i18n::t(locale, "cli.command.config.about"))
82                .mut_subcommand("set", |sub| {
83                    sub.about(crate::i18n::t(locale, "cli.command.config.set.about"))
84                        .mut_arg("key", |arg| {
85                            arg.help(crate::i18n::t(locale, "cli.command.config.set.key"))
86                        })
87                        .mut_arg("value", |arg| {
88                            arg.help(crate::i18n::t(locale, "cli.command.config.set.value"))
89                        })
90                        .mut_arg("file", |arg| {
91                            arg.help(crate::i18n::t(locale, "cli.command.config.set.file"))
92                        })
93                })
94        })
95        .mut_subcommand("mcp", |sub| {
96            sub.about(crate::i18n::t(locale, "cli.command.mcp.about"))
97                .mut_subcommand("doctor", |sub| {
98                    sub.about(crate::i18n::t(locale, "cli.command.mcp.doctor.about"))
99                        .mut_arg("provider", |arg| {
100                            arg.help(crate::i18n::t(locale, "cli.command.mcp.doctor.provider"))
101                        })
102                        .mut_arg("json", |arg| {
103                            arg.help(crate::i18n::t(locale, "cli.command.mcp.doctor.json"))
104                        })
105                })
106        })
107        .mut_subcommand("tools", |sub| {
108            sub.about(crate::i18n::t(locale, "cli.command.tools.about"))
109                .mut_subcommand("install", |sub| {
110                    sub.about(crate::i18n::t(locale, "cli.command.tools.install.about"))
111                        .mut_arg("latest", |arg| {
112                            arg.help(crate::i18n::t(locale, "cli.command.tools.install.latest"))
113                        })
114                })
115        })
116        .mut_subcommand("install", |sub| {
117            sub.about(crate::i18n::t(locale, "cli.command.install.about"))
118                .mut_subcommand("tools", |sub| {
119                    sub.about(crate::i18n::t(locale, "cli.command.install.tools.about"))
120                        .mut_arg("latest", |arg| {
121                            arg.help(crate::i18n::t(locale, "cli.command.tools.install.latest"))
122                        })
123                })
124                .mut_arg("tenant", |arg| {
125                    arg.help(crate::i18n::t(locale, "cli.command.install.tenant"))
126                })
127                .mut_arg("token", |arg| {
128                    arg.help(crate::i18n::t(locale, "cli.command.install.token"))
129                })
130                .mut_arg("bin_dir", |arg| {
131                    arg.help(crate::i18n::t(locale, "cli.command.install.bin_dir"))
132                })
133                .mut_arg("docs_dir", |arg| {
134                    arg.help(crate::i18n::t(locale, "cli.command.install.docs_dir"))
135                })
136                .mut_arg("locale", |arg| {
137                    arg.help(crate::i18n::t(locale, "cli.command.install.locale"))
138                })
139        })
140        .mut_subcommand("release", |sub| {
141            sub.about(crate::i18n::t(locale, "cli.command.release.about"))
142                .mut_subcommand("generate", |sub| {
143                    sub.about(crate::i18n::t(locale, "cli.command.release.generate.about"))
144                        .mut_arg("release", |arg| {
145                            arg.help(crate::i18n::t(locale, "cli.command.release.release"))
146                        })
147                        .mut_arg("from", |arg| {
148                            arg.help(crate::i18n::t(locale, "cli.command.release.from"))
149                        })
150                        .mut_arg("repo", |arg| {
151                            arg.help(crate::i18n::t(locale, "cli.command.release.repo"))
152                        })
153                        .mut_arg("token", |arg| {
154                            arg.help(crate::i18n::t(locale, "cli.command.release.token"))
155                        })
156                        .mut_arg("out", |arg| {
157                            arg.help(crate::i18n::t(locale, "cli.command.release.out"))
158                        })
159                        .mut_arg("dry_run", |arg| {
160                            arg.help(crate::i18n::t(locale, "cli.command.release.dry_run"))
161                        })
162                })
163                .mut_subcommand("publish", |sub| {
164                    sub.about(crate::i18n::t(locale, "cli.command.release.publish.about"))
165                        .mut_arg("release", |arg| {
166                            arg.help(crate::i18n::t(locale, "cli.command.release.release"))
167                        })
168                        .mut_arg("from", |arg| {
169                            arg.help(crate::i18n::t(locale, "cli.command.release.from"))
170                        })
171                        .mut_arg("tag", |arg| {
172                            arg.help(crate::i18n::t(locale, "cli.command.release.tag"))
173                        })
174                        .mut_arg("manifest", |arg| {
175                            arg.help(crate::i18n::t(locale, "cli.command.release.manifest"))
176                        })
177                        .mut_arg("repo", |arg| {
178                            arg.help(crate::i18n::t(locale, "cli.command.release.repo"))
179                        })
180                        .mut_arg("token", |arg| {
181                            arg.help(crate::i18n::t(locale, "cli.command.release.token"))
182                        })
183                        .mut_arg("out", |arg| {
184                            arg.help(crate::i18n::t(locale, "cli.command.release.out"))
185                        })
186                        .mut_arg("dry_run", |arg| {
187                            arg.help(crate::i18n::t(locale, "cli.command.release.dry_run"))
188                        })
189                        .mut_arg("force", |arg| {
190                            arg.help(crate::i18n::t(locale, "cli.command.release.force"))
191                        })
192                })
193                .mut_subcommand("view", |sub| {
194                    sub.about(crate::i18n::t(locale, "cli.command.release.view.about"))
195                        .mut_arg("release", |arg| {
196                            arg.help(crate::i18n::t(locale, "cli.command.release.release"))
197                        })
198                        .mut_arg("tag", |arg| {
199                            arg.help(crate::i18n::t(locale, "cli.command.release.tag"))
200                        })
201                        .mut_arg("repo", |arg| {
202                            arg.help(crate::i18n::t(locale, "cli.command.release.repo"))
203                        })
204                        .mut_arg("token", |arg| {
205                            arg.help(crate::i18n::t(locale, "cli.command.release.token"))
206                        })
207                })
208                .mut_subcommand("latest", |sub| {
209                    sub.about(crate::i18n::t(locale, "cli.command.release.latest.about"))
210                        .mut_arg("repo", |arg| {
211                            arg.help(crate::i18n::t(locale, "cli.command.release.repo"))
212                        })
213                        .mut_arg("token", |arg| {
214                            arg.help(crate::i18n::t(locale, "cli.command.release.token"))
215                        })
216                        .mut_arg("dry_run", |arg| {
217                            arg.help(crate::i18n::t(locale, "cli.command.release.dry_run"))
218                        })
219                        .mut_arg("force", |arg| {
220                            arg.help(crate::i18n::t(locale, "cli.command.release.force"))
221                        })
222                })
223                .mut_subcommand("promote", |sub| {
224                    sub.about(crate::i18n::t(locale, "cli.command.release.promote.about"))
225                        .mut_arg("release", |arg| {
226                            arg.help(crate::i18n::t(locale, "cli.command.release.release"))
227                        })
228                        .mut_arg("tag", |arg| {
229                            arg.help(crate::i18n::t(locale, "cli.command.release.tag"))
230                        })
231                        .mut_arg("repo", |arg| {
232                            arg.help(crate::i18n::t(locale, "cli.command.release.repo"))
233                        })
234                        .mut_arg("token", |arg| {
235                            arg.help(crate::i18n::t(locale, "cli.command.release.token"))
236                        })
237                        .mut_arg("dry_run", |arg| {
238                            arg.help(crate::i18n::t(locale, "cli.command.release.dry_run"))
239                        })
240                })
241        })
242        .mut_subcommand("cbor", |sub| {
243            sub.about(crate::i18n::t(locale, "cli.command.cbor.about"))
244                .mut_arg("path", |arg| {
245                    arg.help(crate::i18n::t(locale, "cli.command.cbor.path"))
246                })
247        })
248        .mut_subcommand("coverage", |sub| {
249            sub.about(crate::i18n::t(locale, "cli.command.coverage.about"))
250                .mut_arg("skip_run", |arg| {
251                    arg.help(crate::i18n::t(locale, "cli.command.coverage.skip_run"))
252                })
253        })
254        .mut_subcommand("security", |sub| {
255            sub.about(crate::i18n::t(locale, "cli.command.security.about"))
256                .mut_arg("format", |arg| {
257                    arg.help(crate::i18n::t(locale, "cli.command.security.format"))
258                })
259                .mut_arg("prompt", |arg| {
260                    arg.help(crate::i18n::t(locale, "cli.command.security.prompt"))
261                })
262                .mut_arg("no_errors", |arg| {
263                    arg.help(crate::i18n::t(locale, "cli.command.security.no_errors"))
264                })
265                .mut_arg("severity", |arg| {
266                    arg.help(crate::i18n::t(locale, "cli.command.security.severity"))
267                })
268                .mut_arg("security_severity", |arg| {
269                    arg.help(crate::i18n::t(
270                        locale,
271                        "cli.command.security.security_severity",
272                    ))
273                })
274                .mut_arg("state", |arg| {
275                    arg.help(crate::i18n::t(locale, "cli.command.security.state"))
276                })
277                .mut_arg("repo", |arg| {
278                    arg.help(crate::i18n::t(locale, "cli.command.security.repo"))
279                })
280                .mut_arg("branch", |arg| {
281                    arg.help(crate::i18n::t(locale, "cli.command.security.branch"))
282                })
283        })
284        .mut_subcommand("wizard", |sub| {
285            sub.about(crate::i18n::t(locale, "cli.command.wizard.about"))
286                .mut_arg("answers", |arg| {
287                    arg.help(crate::i18n::t(locale, "cli.command.wizard.answers"))
288                })
289                .mut_arg("frontend", |arg| {
290                    arg.help(crate::i18n::t(locale, "cli.command.wizard.frontend"))
291                })
292                .mut_arg("locale", |arg| {
293                    arg.help(crate::i18n::t(locale, "cli.command.wizard.locale"))
294                })
295                .mut_arg("emit_answers", |arg| {
296                    arg.help(crate::i18n::t(locale, "cli.command.wizard.emit_answers"))
297                })
298                .mut_arg("schema", |arg| {
299                    arg.help(crate::i18n::t(locale, "cli.command.wizard.schema"))
300                        .long_help(crate::i18n::t(locale, "cli.command.wizard.schema_long"))
301                })
302                .mut_arg("schema_version", |arg| {
303                    arg.help(crate::i18n::t(locale, "cli.command.wizard.schema_version"))
304                })
305                .mut_arg("migrate", |arg| {
306                    arg.help(crate::i18n::t(locale, "cli.command.wizard.migrate"))
307                })
308                .mut_arg("out", |arg| {
309                    arg.help(crate::i18n::t(locale, "cli.command.wizard.out"))
310                })
311                .mut_arg("dry_run", |arg| {
312                    arg.help(crate::i18n::t(locale, "cli.command.wizard.dry_run"))
313                })
314                .mut_arg("yes", |arg| {
315                    arg.help(crate::i18n::t(locale, "cli.command.wizard.yes"))
316                })
317                .mut_arg("non_interactive", |arg| {
318                    arg.help(crate::i18n::t(locale, "cli.command.wizard.non_interactive"))
319                })
320                .mut_arg("unsafe_commands", |arg| {
321                    arg.help(crate::i18n::t(locale, "cli.command.wizard.unsafe_commands"))
322                })
323                .mut_arg("allow_destructive", |arg| {
324                    arg.help(crate::i18n::t(
325                        locale,
326                        "cli.command.wizard.allow_destructive",
327                    ))
328                })
329                .mut_subcommand("validate", |sub| {
330                    sub.about(crate::i18n::t(locale, "cli.command.wizard.validate.about"))
331                        .mut_arg("answers", |arg| {
332                            arg.help(crate::i18n::t(locale, "cli.command.wizard.answers"))
333                        })
334                        .mut_arg("frontend", |arg| {
335                            arg.help(crate::i18n::t(locale, "cli.command.wizard.frontend"))
336                        })
337                        .mut_arg("locale", |arg| {
338                            arg.help(crate::i18n::t(locale, "cli.command.wizard.locale"))
339                        })
340                        .mut_arg("emit_answers", |arg| {
341                            arg.help(crate::i18n::t(locale, "cli.command.wizard.emit_answers"))
342                        })
343                        .mut_arg("schema_version", |arg| {
344                            arg.help(crate::i18n::t(locale, "cli.command.wizard.schema_version"))
345                        })
346                        .mut_arg("migrate", |arg| {
347                            arg.help(crate::i18n::t(locale, "cli.command.wizard.migrate"))
348                        })
349                        .mut_arg("out", |arg| {
350                            arg.help(crate::i18n::t(locale, "cli.command.wizard.out"))
351                        })
352                })
353                .mut_subcommand("apply", |sub| {
354                    sub.about(crate::i18n::t(locale, "cli.command.wizard.apply.about"))
355                        .mut_arg("answers", |arg| {
356                            arg.help(crate::i18n::t(locale, "cli.command.wizard.answers"))
357                        })
358                        .mut_arg("frontend", |arg| {
359                            arg.help(crate::i18n::t(locale, "cli.command.wizard.frontend"))
360                        })
361                        .mut_arg("locale", |arg| {
362                            arg.help(crate::i18n::t(locale, "cli.command.wizard.locale"))
363                        })
364                        .mut_arg("emit_answers", |arg| {
365                            arg.help(crate::i18n::t(locale, "cli.command.wizard.emit_answers"))
366                        })
367                        .mut_arg("schema_version", |arg| {
368                            arg.help(crate::i18n::t(locale, "cli.command.wizard.schema_version"))
369                        })
370                        .mut_arg("migrate", |arg| {
371                            arg.help(crate::i18n::t(locale, "cli.command.wizard.migrate"))
372                        })
373                        .mut_arg("out", |arg| {
374                            arg.help(crate::i18n::t(locale, "cli.command.wizard.out"))
375                        })
376                        .mut_arg("yes", |arg| {
377                            arg.help(crate::i18n::t(locale, "cli.command.wizard.yes"))
378                        })
379                        .mut_arg("non_interactive", |arg| {
380                            arg.help(crate::i18n::t(locale, "cli.command.wizard.non_interactive"))
381                        })
382                        .mut_arg("unsafe_commands", |arg| {
383                            arg.help(crate::i18n::t(locale, "cli.command.wizard.unsafe_commands"))
384                        })
385                        .mut_arg("allow_destructive", |arg| {
386                            arg.help(crate::i18n::t(
387                                locale,
388                                "cli.command.wizard.allow_destructive",
389                            ))
390                        })
391                })
392        });
393
394    localize_help_tree(command, locale, true)
395}
396
397fn localize_help_tree(mut command: clap::Command, locale: &str, is_root: bool) -> clap::Command {
398    command = command
399        .disable_help_subcommand(true)
400        .disable_help_flag(true);
401    let arg_ids = command
402        .get_arguments()
403        .map(|arg| arg.get_id().as_str().to_string())
404        .collect::<Vec<_>>();
405    if arg_ids.iter().any(|id| id == "help") {
406        command = command.mut_arg("help", |arg| {
407            arg.help(crate::i18n::t(locale, "cli.help.flag"))
408        });
409    } else {
410        command = command.arg(
411            Arg::new("help")
412                .short('h')
413                .long("help")
414                .action(ArgAction::Help)
415                .help(crate::i18n::t(locale, "cli.help.flag")),
416        );
417    }
418    if is_root && arg_ids.iter().any(|id| id == "version") {
419        command = command.mut_arg("version", |arg| {
420            arg.help(crate::i18n::t(locale, "cli.version.flag"))
421        });
422    }
423
424    let sub_names = command
425        .get_subcommands()
426        .map(|sub| sub.get_name().to_string())
427        .collect::<Vec<_>>();
428    for name in sub_names {
429        command = command.mut_subcommand(name, |sub| localize_help_tree(sub, locale, false));
430    }
431
432    command
433}
434
435#[derive(Subcommand, Debug)]
436pub enum Command {
437    /// cli.command.flow.about
438    Flow(PassthroughArgs),
439    /// cli.command.pack.about
440    Pack(PassthroughArgs),
441    /// cli.command.component.about
442    Component(PassthroughArgs),
443    /// cli.command.bundle.about
444    Bundle(PassthroughArgs),
445    /// cli.command.runner.about
446    Runner(PassthroughArgs),
447    /// cli.command.config.about
448    #[command(subcommand)]
449    Config(ConfigCommand),
450    /// cli.command.coverage.about
451    Coverage(CoverageArgs),
452    /// cli.command.security.about
453    Security(SecurityArgs),
454    /// cli.command.mcp.about
455    #[command(subcommand)]
456    Mcp(McpCommand),
457    /// cli.command.gui.about
458    Gui(PassthroughArgs),
459    /// cli.command.secrets.about
460    #[command(subcommand)]
461    Secrets(SecretsCommand),
462    /// cli.command.tools.about
463    #[command(subcommand)]
464    Tools(ToolsCommand),
465    /// cli.command.install.about
466    Install(InstallArgs),
467    /// cli.command.release.about
468    #[command(subcommand)]
469    Release(ReleaseCommand),
470    /// cli.command.cbor.about
471    Cbor(CborArgs),
472    /// cli.command.wizard.about
473    Wizard(Box<WizardCommand>),
474}
475
476#[derive(Args, Debug, Clone)]
477#[command(disable_help_flag = true)]
478pub struct PassthroughArgs {
479    /// cli.command.passthrough.args
480    #[arg(
481        value_name = "ARGS",
482        trailing_var_arg = true,
483        allow_hyphen_values = true
484    )]
485    pub args: Vec<OsString>,
486}
487
488#[derive(Subcommand, Debug)]
489pub enum McpCommand {
490    /// cli.command.mcp.doctor.about
491    Doctor(McpDoctorArgs),
492}
493
494#[derive(Args, Debug)]
495pub struct McpDoctorArgs {
496    /// cli.command.mcp.doctor.provider
497    pub provider: String,
498    /// cli.command.mcp.doctor.json
499    #[arg(long = "json")]
500    pub json: bool,
501}
502
503#[derive(Subcommand, Debug)]
504pub enum ConfigCommand {
505    /// cli.command.config.set.about
506    Set(ConfigSetArgs),
507}
508
509#[derive(Subcommand, Debug)]
510pub enum ToolsCommand {
511    /// cli.command.tools.install.about
512    Install(ToolsInstallArgs),
513}
514
515#[derive(Subcommand, Debug)]
516pub enum InstallSubcommand {
517    /// cli.command.install.tools.about
518    Tools(ToolsInstallArgs),
519}
520
521#[derive(Subcommand, Debug)]
522pub enum ReleaseCommand {
523    /// cli.command.release.generate.about
524    Generate(ReleaseGenerateArgs),
525    /// cli.command.release.publish.about
526    Publish(ReleasePublishArgs),
527    /// cli.command.release.view.about
528    View(ReleaseViewArgs),
529    /// cli.command.release.latest.about
530    Latest(ReleaseLatestArgs),
531    /// cli.command.release.promote.about
532    Promote(ReleasePromoteArgs),
533}
534
535#[derive(Args, Debug)]
536pub struct InstallArgs {
537    #[command(subcommand)]
538    pub command: Option<InstallSubcommand>,
539    /// cli.command.install.tenant
540    #[arg(long = "tenant")]
541    pub tenant: Option<String>,
542    /// cli.command.install.token
543    #[arg(long = "token")]
544    pub token: Option<String>,
545    /// cli.command.install.bin_dir
546    #[arg(long = "bin-dir")]
547    pub bin_dir: Option<PathBuf>,
548    /// cli.command.install.docs_dir
549    #[arg(long = "docs-dir")]
550    pub docs_dir: Option<PathBuf>,
551    /// cli.command.install.locale
552    #[arg(long = "locale")]
553    pub locale: Option<String>,
554}
555
556#[derive(Args, Debug)]
557pub struct ToolsInstallArgs {
558    /// cli.command.tools.install.latest
559    #[arg(long = "latest")]
560    pub latest: bool,
561}
562
563#[derive(Args, Debug)]
564pub struct ReleaseGenerateArgs {
565    /// cli.command.release.release
566    #[arg(long = "release")]
567    pub release: String,
568    /// cli.command.release.from
569    #[arg(long = "from", default_value = "latest")]
570    pub from: String,
571    /// cli.command.release.repo
572    #[arg(
573        long = "repo",
574        default_value = "ghcr.io/greenticai/greentic-versions/gtc"
575    )]
576    pub repo: String,
577    /// cli.command.release.token
578    #[arg(long = "token")]
579    pub token: Option<String>,
580    /// cli.command.release.out
581    #[arg(long = "out", default_value = "dist/toolchains")]
582    pub out: PathBuf,
583    /// cli.command.release.dry_run
584    #[arg(long = "dry-run")]
585    pub dry_run: bool,
586}
587
588#[derive(Args, Debug)]
589pub struct ReleasePublishArgs {
590    /// cli.command.release.release
591    #[arg(long = "release", required_unless_present = "manifest")]
592    pub release: Option<String>,
593    /// cli.command.release.from
594    #[arg(long = "from", default_value = "latest", requires = "release")]
595    pub from: Option<String>,
596    /// cli.command.release.tag
597    #[arg(long = "tag")]
598    pub tag: Option<String>,
599    /// cli.command.release.manifest
600    #[arg(long = "manifest", required_unless_present = "release")]
601    pub manifest: Option<PathBuf>,
602    /// cli.command.release.repo
603    #[arg(
604        long = "repo",
605        default_value = "ghcr.io/greenticai/greentic-versions/gtc"
606    )]
607    pub repo: String,
608    /// cli.command.release.token
609    #[arg(long = "token")]
610    pub token: Option<String>,
611    /// cli.command.release.out
612    #[arg(long = "out", default_value = "dist/toolchains")]
613    pub out: PathBuf,
614    /// cli.command.release.dry_run
615    #[arg(long = "dry-run")]
616    pub dry_run: bool,
617    /// cli.command.release.force
618    #[arg(long = "force")]
619    pub force: bool,
620}
621
622#[derive(Args, Debug)]
623pub struct ReleaseViewArgs {
624    /// cli.command.release.release
625    #[arg(
626        long = "release",
627        conflicts_with = "tag",
628        required_unless_present = "tag"
629    )]
630    pub release: Option<String>,
631    /// cli.command.release.tag
632    #[arg(
633        long = "tag",
634        conflicts_with = "release",
635        required_unless_present = "release"
636    )]
637    pub tag: Option<String>,
638    /// cli.command.release.repo
639    #[arg(
640        long = "repo",
641        default_value = "ghcr.io/greenticai/greentic-versions/gtc"
642    )]
643    pub repo: String,
644    /// cli.command.release.token
645    #[arg(long = "token")]
646    pub token: Option<String>,
647}
648
649#[derive(Args, Debug)]
650pub struct ReleaseLatestArgs {
651    /// cli.command.release.repo
652    #[arg(
653        long = "repo",
654        default_value = "ghcr.io/greenticai/greentic-versions/gtc"
655    )]
656    pub repo: String,
657    /// cli.command.release.token
658    #[arg(long = "token")]
659    pub token: Option<String>,
660    /// cli.command.release.dry_run
661    #[arg(long = "dry-run")]
662    pub dry_run: bool,
663    /// cli.command.release.force
664    #[arg(long = "force")]
665    pub force: bool,
666}
667
668#[derive(Args, Debug)]
669pub struct ReleasePromoteArgs {
670    /// cli.command.release.release
671    #[arg(long = "release")]
672    pub release: String,
673    /// cli.command.release.tag
674    #[arg(long = "tag")]
675    pub tag: String,
676    /// cli.command.release.repo
677    #[arg(
678        long = "repo",
679        default_value = "ghcr.io/greenticai/greentic-versions/gtc"
680    )]
681    pub repo: String,
682    /// cli.command.release.token
683    #[arg(long = "token")]
684    pub token: Option<String>,
685    /// cli.command.release.dry_run
686    #[arg(long = "dry-run")]
687    pub dry_run: bool,
688}
689
690#[derive(Args, Debug)]
691pub struct ConfigSetArgs {
692    /// cli.command.config.set.key
693    pub key: String,
694    /// cli.command.config.set.value
695    pub value: String,
696    /// cli.command.config.set.file
697    #[arg(long = "file")]
698    pub file: Option<PathBuf>,
699}
700
701#[derive(Args, Debug)]
702pub struct CborArgs {
703    /// cli.command.cbor.path
704    #[arg(value_name = "PATH")]
705    pub path: PathBuf,
706}
707
708#[derive(Args, Debug, Clone)]
709pub struct CoverageArgs {
710    /// cli.command.coverage.skip_run
711    #[arg(long = "skip-run")]
712    pub skip_run: bool,
713}
714
715#[derive(Clone, Copy, Debug, Eq, PartialEq, clap::ValueEnum)]
716pub enum SecurityFormat {
717    Markdown,
718    Json,
719}
720
721#[derive(Args, Debug, Clone)]
722pub struct SecurityArgs {
723    /// cli.command.security.format
724    #[arg(long = "format", value_enum, default_value_t = SecurityFormat::Markdown)]
725    pub format: SecurityFormat,
726    /// cli.command.security.prompt
727    #[arg(long = "prompt")]
728    pub prompt: bool,
729    /// cli.command.security.no_errors
730    #[arg(long = "ignore-errors", alias = "no-errors")]
731    pub no_errors: bool,
732    /// cli.command.security.severity
733    #[arg(long = "severity")]
734    pub severity: Option<String>,
735    /// cli.command.security.security_severity
736    #[arg(long = "security-severity")]
737    pub security_severity: Option<String>,
738    /// cli.command.security.state
739    #[arg(long = "state", default_value = "open")]
740    pub state: String,
741    /// cli.command.security.repo
742    #[arg(long = "repo")]
743    pub repo: Option<String>,
744    /// cli.command.security.branch
745    #[arg(long = "branch")]
746    pub branch: Option<String>,
747}
748
749#[derive(Args, Debug, Clone)]
750pub struct WizardCommand {
751    #[command(subcommand)]
752    pub command: Option<WizardSubcommand>,
753    #[command(flatten)]
754    pub launch: WizardLaunchArgs,
755}
756
757#[derive(Subcommand, Debug, Clone)]
758pub enum WizardSubcommand {
759    /// cli.command.wizard.validate.about
760    Validate(WizardValidateArgs),
761    /// cli.command.wizard.apply.about
762    Apply(WizardApplyArgs),
763}
764
765#[derive(Args, Debug, Clone)]
766pub struct WizardLaunchArgs {
767    /// cli.command.wizard.answers (local path or http/https URL)
768    #[arg(long = "answers")]
769    pub answers: Option<String>,
770    /// cli.command.wizard.frontend
771    #[arg(long = "frontend", default_value = "json")]
772    pub frontend: String,
773    /// cli.command.wizard.locale
774    #[arg(long = "locale")]
775    pub locale: Option<String>,
776    /// cli.command.wizard.emit_answers
777    #[arg(long = "emit-answers")]
778    pub emit_answers: Option<PathBuf>,
779    /// cli.command.wizard.schema
780    #[arg(long = "schema")]
781    pub schema: bool,
782    /// cli.command.wizard.schema_version
783    #[arg(long = "schema-version")]
784    pub schema_version: Option<String>,
785    /// cli.command.wizard.migrate
786    #[arg(long = "migrate")]
787    pub migrate: bool,
788    /// cli.command.wizard.out
789    #[arg(long = "out")]
790    pub out: Option<PathBuf>,
791    /// cli.command.wizard.dry_run
792    #[arg(long = "dry-run")]
793    pub dry_run: bool,
794    /// cli.command.wizard.yes
795    #[arg(long = "yes")]
796    pub yes: bool,
797    /// cli.command.wizard.non_interactive
798    #[arg(long = "non-interactive")]
799    pub non_interactive: bool,
800    /// cli.command.wizard.unsafe_commands
801    #[arg(long = "unsafe-commands")]
802    pub unsafe_commands: bool,
803    /// cli.command.wizard.allow_destructive
804    #[arg(long = "allow-destructive")]
805    pub allow_destructive: bool,
806}
807
808#[derive(Args, Debug, Clone)]
809pub struct WizardValidateArgs {
810    /// cli.command.wizard.answers (local path or http/https URL)
811    #[arg(long = "answers")]
812    pub answers: String,
813    /// cli.command.wizard.frontend
814    #[arg(long = "frontend", default_value = "json")]
815    pub frontend: String,
816    /// cli.command.wizard.locale
817    #[arg(long = "locale")]
818    pub locale: Option<String>,
819    /// cli.command.wizard.emit_answers
820    #[arg(long = "emit-answers")]
821    pub emit_answers: Option<PathBuf>,
822    /// cli.command.wizard.schema_version
823    #[arg(long = "schema-version")]
824    pub schema_version: Option<String>,
825    /// cli.command.wizard.migrate
826    #[arg(long = "migrate")]
827    pub migrate: bool,
828    /// cli.command.wizard.out
829    #[arg(long = "out")]
830    pub out: Option<PathBuf>,
831}
832
833#[derive(Args, Debug, Clone)]
834pub struct WizardApplyArgs {
835    /// cli.command.wizard.answers (local path or http/https URL)
836    #[arg(long = "answers")]
837    pub answers: String,
838    /// cli.command.wizard.frontend
839    #[arg(long = "frontend", default_value = "json")]
840    pub frontend: String,
841    /// cli.command.wizard.locale
842    #[arg(long = "locale")]
843    pub locale: Option<String>,
844    /// cli.command.wizard.emit_answers
845    #[arg(long = "emit-answers")]
846    pub emit_answers: Option<PathBuf>,
847    /// cli.command.wizard.schema_version
848    #[arg(long = "schema-version")]
849    pub schema_version: Option<String>,
850    /// cli.command.wizard.migrate
851    #[arg(long = "migrate")]
852    pub migrate: bool,
853    /// cli.command.wizard.out
854    #[arg(long = "out")]
855    pub out: Option<PathBuf>,
856    /// cli.command.wizard.yes
857    #[arg(long = "yes")]
858    pub yes: bool,
859    /// cli.command.wizard.non_interactive
860    #[arg(long = "non-interactive")]
861    pub non_interactive: bool,
862    /// cli.command.wizard.unsafe_commands
863    #[arg(long = "unsafe-commands")]
864    pub unsafe_commands: bool,
865    /// cli.command.wizard.allow_destructive
866    #[arg(long = "allow-destructive")]
867    pub allow_destructive: bool,
868}