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(FlowValidateArgs),
51 AddStep(FlowAddStepArgs),
53}
54
55#[derive(Args, Debug)]
56pub struct FlowValidateArgs {
57 #[arg(short = 'f', long = "file")]
59 pub file: PathBuf,
60 #[arg(long = "json")]
62 pub json: bool,
63}
64
65#[derive(Args, Debug)]
66pub struct FlowAddStepArgs {
67 #[arg(long = "manifest")]
69 pub manifest: Option<PathBuf>,
70 #[arg(long = "flow", default_value = "default")]
72 pub flow: String,
73 pub flow_id: String,
75 #[arg(long = "coordinate")]
77 pub coordinate: Option<String>,
78 #[arg(long = "profile")]
80 pub profile: Option<String>,
81 #[arg(long = "mode", value_enum)]
83 pub mode: Option<ConfigFlowModeArg>,
84 #[arg(long = "after")]
86 pub after: Option<String>,
87}
88
89#[derive(Subcommand, Debug)]
90pub enum GuiCommand {
91 Serve(GuiServeArgs),
93 PackDev(GuiPackDevArgs),
95}
96
97#[derive(Args, Debug)]
98pub struct GuiServeArgs {
99 #[arg(long = "config")]
101 pub config: Option<PathBuf>,
102 #[arg(long = "bind")]
104 pub bind: Option<String>,
105 #[arg(long = "domain")]
107 pub domain: Option<String>,
108 #[arg(long = "gui-bin")]
110 pub gui_bin: Option<PathBuf>,
111 #[arg(long = "no-cargo-fallback")]
113 pub no_cargo_fallback: bool,
114 #[arg(long = "open-browser")]
116 pub open_browser: bool,
117}
118
119#[derive(Args, Debug, Clone)]
120pub struct GuiPackDevArgs {
121 #[arg(long = "dir")]
123 pub dir: PathBuf,
124 #[arg(long = "output")]
126 pub output: PathBuf,
127 #[arg(long = "kind", value_enum, default_value = "layout")]
129 pub kind: GuiPackKind,
130 #[arg(long = "entrypoint", default_value = "index.html")]
132 pub entrypoint: String,
133 #[arg(long = "manifest")]
135 pub manifest: Option<PathBuf>,
136 #[arg(long = "feature-route")]
138 pub feature_route: Option<String>,
139 #[arg(long = "feature-html", default_value = "index.html")]
141 pub feature_html: String,
142 #[arg(long = "feature-authenticated")]
144 pub feature_authenticated: bool,
145 #[arg(long = "build-cmd")]
147 pub build_cmd: Option<String>,
148 #[arg(long = "no-build")]
150 pub no_build: bool,
151}
152
153#[derive(ValueEnum, Debug, Clone, Copy, PartialEq, Eq)]
154pub enum GuiPackKind {
155 Layout,
156 Feature,
157}
158
159#[derive(Subcommand, Debug)]
160pub enum PackCommand {
161 Build(PackcArgs),
163 Lint(PackcArgs),
165 Components(PackcArgs),
167 Update(PackcArgs),
169 New(PackcArgs),
171 Sign(PackcArgs),
173 Verify(PackcArgs),
175 Gui(PackcArgs),
177 Inspect(PackInspectArgs),
179 Plan(PackPlanArgs),
181 #[command(subcommand)]
183 Events(PackEventsCommand),
184 Config(PackcArgs),
186 Run(PackRunArgs),
188 Init(PackInitArgs),
190 NewProvider(PackNewProviderArgs),
192}
193
194#[derive(Args, Debug)]
195pub struct PackRunArgs {
196 #[arg(short = 'p', long = "pack")]
198 pub pack: PathBuf,
199 #[arg(long = "entry")]
201 pub entry: Option<String>,
202 #[arg(long = "input")]
204 pub input: Option<String>,
205 #[arg(long = "json")]
207 pub json: bool,
208 #[arg(long = "offline")]
210 pub offline: bool,
211 #[arg(long = "mock-exec", hide = true)]
213 pub mock_exec: bool,
214 #[arg(long = "allow-external", hide = true)]
216 pub allow_external: bool,
217 #[arg(long = "mock-external", hide = true)]
219 pub mock_external: bool,
220 #[arg(long = "mock-external-payload", hide = true)]
222 pub mock_external_payload: Option<PathBuf>,
223 #[arg(long = "secrets-seed", hide = true)]
225 pub secrets_seed: Option<PathBuf>,
226 #[arg(long = "policy", default_value = "devok", value_enum)]
228 pub policy: RunPolicyArg,
229 #[arg(long = "otlp")]
231 pub otlp: Option<String>,
232 #[arg(long = "allow")]
234 pub allow: Option<String>,
235 #[arg(long = "mocks", default_value = "on", value_enum)]
237 pub mocks: MockSettingArg,
238 #[arg(long = "artifacts")]
240 pub artifacts: Option<PathBuf>,
241}
242
243#[derive(Args, Debug)]
244pub struct PackInitArgs {
245 pub from: String,
247 #[arg(long = "profile")]
249 pub profile: Option<String>,
250}
251
252#[derive(Args, Debug)]
253pub struct PackNewProviderArgs {
254 #[arg(long = "pack")]
256 pub pack: PathBuf,
257 #[arg(long = "id")]
259 pub id: String,
260 #[arg(long = "runtime")]
262 pub runtime: String,
263 #[arg(long = "kind")]
265 pub kind: Option<String>,
266 #[arg(long = "manifest")]
268 pub manifest: Option<PathBuf>,
269 #[arg(long = "dry-run")]
271 pub dry_run: bool,
272 #[arg(long = "force")]
274 pub force: bool,
275 #[arg(long = "json")]
277 pub json: bool,
278 #[arg(long = "scaffold-files")]
280 pub scaffold_files: bool,
281}
282
283#[derive(Args, Debug, Clone, Default)]
284#[command(disable_help_flag = true)]
285pub struct PackcArgs {
286 #[arg(
288 value_name = "ARGS",
289 trailing_var_arg = true,
290 allow_hyphen_values = true
291 )]
292 pub passthrough: Vec<String>,
293}
294
295#[derive(Args, Debug)]
296pub struct PackInspectArgs {
297 #[arg(value_name = "PATH")]
299 pub path: PathBuf,
300 #[arg(long, value_enum, default_value = "devok")]
302 pub policy: PackPolicyArg,
303 #[arg(long)]
305 pub json: bool,
306}
307
308#[derive(Subcommand, Debug)]
309pub enum PackEventsCommand {
310 List(PackEventsListArgs),
312}
313
314#[derive(Args, Debug)]
315pub struct PackEventsListArgs {
316 #[arg(value_name = "PATH")]
318 pub path: PathBuf,
319 #[arg(long, value_enum, default_value = "table")]
321 pub format: PackEventsFormatArg,
322 #[arg(long)]
324 pub verbose: bool,
325}
326
327#[derive(Args, Debug)]
328pub struct PackPlanArgs {
329 #[arg(value_name = "PATH")]
331 pub input: PathBuf,
332 #[arg(long, default_value = "tenant-local")]
334 pub tenant: String,
335 #[arg(long, default_value = "local")]
337 pub environment: String,
338 #[arg(long)]
340 pub json: bool,
341 #[arg(long)]
343 pub verbose: bool,
344}
345
346#[derive(Subcommand, Debug, Clone)]
347pub enum ComponentCommand {
348 Add(ComponentAddArgs),
350 New(ComponentNewArgs),
352 Templates(ComponentTemplatesArgs),
354 Doctor(ComponentDoctorArgs),
356 Inspect(ComponentInspectArgs),
358 Hash(ComponentHashArgs),
360 Build(ComponentBuildArgs),
362 #[command(subcommand)]
364 Flow(ComponentFlowCommand),
365 #[command(subcommand)]
367 Store(ComponentStoreCommand),
368}
369
370#[derive(Args, Debug, Clone)]
371pub struct ComponentAddArgs {
372 pub coordinate: String,
374 #[arg(long = "profile")]
376 pub profile: Option<String>,
377 #[arg(long = "intent", default_value = "dev", value_enum)]
379 pub intent: DevIntentArg,
380}
381
382#[derive(Subcommand, Debug)]
383pub enum McpCommand {
384 Doctor(McpDoctorArgs),
386}
387
388#[derive(Args, Debug)]
389pub struct McpDoctorArgs {
390 pub provider: String,
392 #[arg(long = "json")]
394 pub json: bool,
395}
396
397#[derive(Subcommand, Debug)]
398pub enum ConfigCommand {
399 Set(ConfigSetArgs),
401}
402
403#[derive(Args, Debug)]
404pub struct ConfigSetArgs {
405 pub key: String,
407 pub value: String,
409 #[arg(long = "file")]
411 pub file: Option<PathBuf>,
412}
413
414#[derive(Copy, Clone, Debug, ValueEnum)]
415pub enum PackSignArg {
416 Dev,
417 None,
418}
419
420#[derive(Copy, Clone, Debug, ValueEnum)]
421pub enum PackPolicyArg {
422 Devok,
423 Strict,
424}
425
426#[derive(Copy, Clone, Debug, ValueEnum)]
427pub enum RunPolicyArg {
428 Strict,
429 Devok,
430}
431
432#[derive(Copy, Clone, Debug, ValueEnum)]
433pub enum VerifyPolicyArg {
434 Strict,
435 Devok,
436}
437
438#[derive(Copy, Clone, Debug, ValueEnum)]
439pub enum MockSettingArg {
440 On,
441 Off,
442}
443
444#[derive(Copy, Clone, Debug, ValueEnum)]
445pub enum PackEventsFormatArg {
446 Table,
447 Json,
448 Yaml,
449}
450
451#[derive(Copy, Clone, Debug, ValueEnum)]
452pub enum ConfigFlowModeArg {
453 Default,
454 Custom,
455}
456#[derive(Copy, Clone, Debug, ValueEnum)]
457pub enum DevIntentArg {
458 Dev,
459 Runtime,
460}
461
462#[cfg(test)]
463mod tests {}