1use std::path::PathBuf;
2
3use crate::secrets_cli::SecretsCommand;
4use clap::{Args, Parser, Subcommand, ValueEnum};
5use greentic_component::cmd::{
6 build::BuildArgs as ComponentBuildArgs, doctor::DoctorArgs as ComponentDoctorArgs,
7 flow::FlowCommand as ComponentFlowCommand, hash::HashArgs as ComponentHashArgs,
8 inspect::InspectArgs as ComponentInspectArgs, new::NewArgs as ComponentNewArgs,
9 store::StoreCommand as ComponentStoreCommand,
10 templates::TemplatesArgs as ComponentTemplatesArgs,
11};
12
13#[derive(Parser, Debug)]
14#[command(name = "greentic-dev")]
15#[command(version)]
16#[command(about = "Greentic developer tooling CLI")]
17pub struct Cli {
18 #[command(subcommand)]
19 pub command: Command,
20}
21
22#[derive(Subcommand, Debug)]
23pub enum Command {
24 #[command(subcommand)]
26 Flow(FlowCommand),
27 #[command(subcommand)]
29 Pack(PackCommand),
30 #[command(subcommand)]
32 Component(ComponentCommand),
33 #[command(subcommand)]
35 Config(ConfigCommand),
36 #[command(subcommand)]
38 Mcp(McpCommand),
39 #[command(subcommand)]
41 Gui(GuiCommand),
42 #[command(subcommand)]
44 Secrets(SecretsCommand),
45}
46
47#[derive(Subcommand, Debug)]
48pub enum FlowCommand {
49 Validate(FlowDoctorArgs),
51 Doctor(FlowDoctorArgs),
53 AddStep(Box<FlowAddStepArgs>),
55}
56
57#[derive(Args, Debug)]
58pub struct FlowDoctorArgs {
59 #[arg(
61 value_name = "ARGS",
62 trailing_var_arg = true,
63 allow_hyphen_values = true
64 )]
65 pub passthrough: Vec<String>,
66}
67
68#[derive(Args, Debug)]
69pub struct FlowAddStepArgs {
70 #[arg(long = "flow")]
72 pub flow_path: PathBuf,
73 #[arg(long = "after")]
75 pub after: Option<String>,
76 #[arg(long = "mode", value_enum, default_value = "default")]
78 pub mode: FlowAddStepMode,
79 #[arg(long = "component")]
81 pub component_id: Option<String>,
82 #[arg(long = "pack-alias")]
84 pub pack_alias: Option<String>,
85 #[arg(long = "operation")]
87 pub operation: Option<String>,
88 #[arg(long = "payload", default_value = "{}")]
90 pub payload: String,
91 #[arg(long = "routing")]
93 pub routing: Option<String>,
94 #[arg(long = "config-flow")]
96 pub config_flow: Option<PathBuf>,
97 #[arg(long = "answers")]
99 pub answers: Option<String>,
100 #[arg(long = "answers-file")]
102 pub answers_file: Option<PathBuf>,
103 #[arg(long = "allow-cycles")]
105 pub allow_cycles: bool,
106 #[arg(long = "write")]
108 pub write: bool,
109 #[arg(long = "validate-only")]
111 pub validate_only: bool,
112 #[arg(long = "manifest")]
114 pub manifests: Vec<PathBuf>,
115 #[arg(long = "node-id")]
117 pub node_id: Option<String>,
118 #[arg(long = "verbose")]
120 pub verbose: bool,
121}
122
123#[derive(Copy, Clone, Debug, Eq, PartialEq, ValueEnum)]
124pub enum FlowAddStepMode {
125 Default,
126 Config,
127}
128
129#[derive(Subcommand, Debug)]
130pub enum GuiCommand {
131 Serve(GuiServeArgs),
133 PackDev(GuiPackDevArgs),
135}
136
137#[derive(Args, Debug)]
138pub struct GuiServeArgs {
139 #[arg(long = "config")]
141 pub config: Option<PathBuf>,
142 #[arg(long = "bind")]
144 pub bind: Option<String>,
145 #[arg(long = "domain")]
147 pub domain: Option<String>,
148 #[arg(long = "gui-bin")]
150 pub gui_bin: Option<PathBuf>,
151 #[arg(long = "no-cargo-fallback")]
153 pub no_cargo_fallback: bool,
154 #[arg(long = "open-browser")]
156 pub open_browser: bool,
157}
158
159#[derive(Args, Debug, Clone)]
160pub struct GuiPackDevArgs {
161 #[arg(long = "dir")]
163 pub dir: PathBuf,
164 #[arg(long = "output")]
166 pub output: PathBuf,
167 #[arg(long = "kind", value_enum, default_value = "layout")]
169 pub kind: GuiPackKind,
170 #[arg(long = "entrypoint", default_value = "index.html")]
172 pub entrypoint: String,
173 #[arg(long = "manifest")]
175 pub manifest: Option<PathBuf>,
176 #[arg(long = "feature-route")]
178 pub feature_route: Option<String>,
179 #[arg(long = "feature-html", default_value = "index.html")]
181 pub feature_html: String,
182 #[arg(long = "feature-authenticated")]
184 pub feature_authenticated: bool,
185 #[arg(long = "build-cmd")]
187 pub build_cmd: Option<String>,
188 #[arg(long = "no-build")]
190 pub no_build: bool,
191}
192
193#[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq)]
194pub enum GuiPackKind {
195 Layout,
196 Feature,
197}
198
199#[derive(Subcommand, Debug)]
200pub enum PackCommand {
201 Build(PackcArgs),
203 Lint(PackcArgs),
205 Components(PackcArgs),
207 Update(PackcArgs),
209 New(PackcArgs),
211 Sign(PackcArgs),
213 Verify(PackcArgs),
215 Gui(PackcArgs),
217 Inspect(PackInspectArgs),
219 Doctor(PackInspectArgs),
221 Plan(PackPlanArgs),
223 #[command(subcommand)]
225 Events(PackEventsCommand),
226 Config(PackcArgs),
228 Run(PackRunArgs),
230 Init(PackInitArgs),
232 NewProvider(PackNewProviderArgs),
234}
235
236#[derive(Args, Debug)]
237pub struct PackRunArgs {
238 #[arg(short = 'p', long = "pack")]
240 pub pack: PathBuf,
241 #[arg(long = "entry")]
243 pub entry: Option<String>,
244 #[arg(long = "input")]
246 pub input: Option<String>,
247 #[arg(long = "json")]
249 pub json: bool,
250 #[arg(long = "offline")]
252 pub offline: bool,
253 #[arg(long = "mock-exec", hide = true)]
255 pub mock_exec: bool,
256 #[arg(long = "allow-external", hide = true)]
258 pub allow_external: bool,
259 #[arg(long = "mock-external", hide = true)]
261 pub mock_external: bool,
262 #[arg(long = "mock-external-payload", hide = true)]
264 pub mock_external_payload: Option<PathBuf>,
265 #[arg(long = "secrets-seed", hide = true)]
267 pub secrets_seed: Option<PathBuf>,
268 #[arg(long = "policy", default_value = "devok", value_enum)]
270 pub policy: RunPolicyArg,
271 #[arg(long = "otlp")]
273 pub otlp: Option<String>,
274 #[arg(long = "allow")]
276 pub allow: Option<String>,
277 #[arg(long = "mocks", default_value = "on", value_enum)]
279 pub mocks: MockSettingArg,
280 #[arg(long = "artifacts")]
282 pub artifacts: Option<PathBuf>,
283}
284
285#[derive(Args, Debug)]
286pub struct PackInitArgs {
287 pub from: String,
289 #[arg(long = "profile")]
291 pub profile: Option<String>,
292}
293
294#[derive(Args, Debug)]
295pub struct PackNewProviderArgs {
296 #[arg(long = "pack")]
298 pub pack: PathBuf,
299 #[arg(long = "id")]
301 pub id: String,
302 #[arg(long = "runtime")]
304 pub runtime: String,
305 #[arg(long = "kind")]
307 pub kind: Option<String>,
308 #[arg(long = "manifest")]
310 pub manifest: Option<PathBuf>,
311 #[arg(long = "dry-run")]
313 pub dry_run: bool,
314 #[arg(long = "force")]
316 pub force: bool,
317 #[arg(long = "json")]
319 pub json: bool,
320 #[arg(long = "scaffold-files")]
322 pub scaffold_files: bool,
323}
324
325#[derive(Args, Debug, Clone, Default)]
326#[command(disable_help_flag = true)]
327pub struct PackcArgs {
328 #[arg(
330 value_name = "ARGS",
331 trailing_var_arg = true,
332 allow_hyphen_values = true
333 )]
334 pub passthrough: Vec<String>,
335}
336
337#[derive(Args, Debug)]
338pub struct PackInspectArgs {
339 #[arg(value_name = "PATH")]
341 pub path: PathBuf,
342 #[arg(long, value_enum, default_value = "devok")]
344 pub policy: PackPolicyArg,
345 #[arg(long)]
347 pub json: bool,
348}
349
350#[derive(Subcommand, Debug)]
351pub enum PackEventsCommand {
352 List(PackEventsListArgs),
354}
355
356#[derive(Args, Debug)]
357pub struct PackEventsListArgs {
358 #[arg(value_name = "PATH")]
360 pub path: PathBuf,
361 #[arg(long, value_enum, default_value = "table")]
363 pub format: PackEventsFormatArg,
364 #[arg(long)]
366 pub verbose: bool,
367}
368
369#[derive(Args, Debug)]
370pub struct PackPlanArgs {
371 #[arg(value_name = "PATH")]
373 pub input: PathBuf,
374 #[arg(long, default_value = "tenant-local")]
376 pub tenant: String,
377 #[arg(long, default_value = "local")]
379 pub environment: String,
380 #[arg(long)]
382 pub json: bool,
383 #[arg(long)]
385 pub verbose: bool,
386}
387
388#[derive(Subcommand, Debug, Clone)]
389pub enum ComponentCommand {
390 Add(ComponentAddArgs),
392 New(ComponentNewArgs),
394 Templates(ComponentTemplatesArgs),
396 Doctor(ComponentDoctorArgs),
398 Inspect(ComponentInspectArgs),
400 Hash(ComponentHashArgs),
402 Build(ComponentBuildArgs),
404 #[command(subcommand)]
406 Flow(ComponentFlowCommand),
407 #[command(subcommand)]
409 Store(ComponentStoreCommand),
410}
411
412#[derive(Args, Debug, Clone)]
413pub struct ComponentAddArgs {
414 pub coordinate: String,
416 #[arg(long = "profile")]
418 pub profile: Option<String>,
419 #[arg(long = "intent", default_value = "dev", value_enum)]
421 pub intent: DevIntentArg,
422}
423
424#[derive(Subcommand, Debug)]
425pub enum McpCommand {
426 Doctor(McpDoctorArgs),
428}
429
430#[derive(Args, Debug)]
431pub struct McpDoctorArgs {
432 pub provider: String,
434 #[arg(long = "json")]
436 pub json: bool,
437}
438
439#[derive(Subcommand, Debug)]
440pub enum ConfigCommand {
441 Set(ConfigSetArgs),
443}
444
445#[derive(Args, Debug)]
446pub struct ConfigSetArgs {
447 pub key: String,
449 pub value: String,
451 #[arg(long = "file")]
453 pub file: Option<PathBuf>,
454}
455
456#[derive(Copy, Clone, Debug, ValueEnum)]
457pub enum PackSignArg {
458 Dev,
459 None,
460}
461
462#[derive(Copy, Clone, Debug, ValueEnum)]
463pub enum PackPolicyArg {
464 Devok,
465 Strict,
466}
467
468#[derive(Copy, Clone, Debug, ValueEnum)]
469pub enum RunPolicyArg {
470 Strict,
471 Devok,
472}
473
474#[derive(Copy, Clone, Debug, ValueEnum)]
475pub enum VerifyPolicyArg {
476 Strict,
477 Devok,
478}
479
480#[derive(Copy, Clone, Debug, ValueEnum)]
481pub enum MockSettingArg {
482 On,
483 Off,
484}
485
486#[derive(Copy, Clone, Debug, ValueEnum)]
487pub enum PackEventsFormatArg {
488 Table,
489 Json,
490 Yaml,
491}
492
493#[derive(Copy, Clone, Debug, ValueEnum)]
494pub enum ConfigFlowModeArg {
495 Default,
496 Custom,
497}
498#[derive(Copy, Clone, Debug, ValueEnum)]
499pub enum DevIntentArg {
500 Dev,
501 Runtime,
502}
503
504#[cfg(test)]
505mod tests {}