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 New(PackcArgs),
167 Sign(PackcArgs),
169 Verify(PackcArgs),
171 Inspect(PackInspectArgs),
173 Plan(PackPlanArgs),
175 #[command(subcommand)]
177 Events(PackEventsCommand),
178 Run(PackRunArgs),
180 Init(PackInitArgs),
182}
183
184#[derive(Args, Debug)]
185pub struct PackRunArgs {
186 #[arg(short = 'p', long = "pack")]
188 pub pack: PathBuf,
189 #[arg(long = "entry")]
191 pub entry: Option<String>,
192 #[arg(long = "input")]
194 pub input: Option<String>,
195 #[arg(long = "json")]
197 pub json: bool,
198 #[arg(long = "offline")]
200 pub offline: bool,
201 #[arg(long = "mock-exec", hide = true)]
203 pub mock_exec: bool,
204 #[arg(long = "allow-external", hide = true)]
206 pub allow_external: bool,
207 #[arg(long = "mock-external", hide = true)]
209 pub mock_external: bool,
210 #[arg(long = "mock-external-payload", hide = true)]
212 pub mock_external_payload: Option<PathBuf>,
213 #[arg(long = "secrets-seed", hide = true)]
215 pub secrets_seed: Option<PathBuf>,
216 #[arg(long = "policy", default_value = "devok", value_enum)]
218 pub policy: RunPolicyArg,
219 #[arg(long = "otlp")]
221 pub otlp: Option<String>,
222 #[arg(long = "allow")]
224 pub allow: Option<String>,
225 #[arg(long = "mocks", default_value = "on", value_enum)]
227 pub mocks: MockSettingArg,
228 #[arg(long = "artifacts")]
230 pub artifacts: Option<PathBuf>,
231}
232
233#[derive(Args, Debug)]
234pub struct PackInitArgs {
235 pub from: String,
237 #[arg(long = "profile")]
239 pub profile: Option<String>,
240}
241
242#[derive(Args, Debug, Clone, Default)]
243#[command(disable_help_flag = true)]
244pub struct PackcArgs {
245 #[arg(
247 value_name = "ARGS",
248 trailing_var_arg = true,
249 allow_hyphen_values = true
250 )]
251 pub passthrough: Vec<String>,
252}
253
254#[derive(Args, Debug)]
255pub struct PackInspectArgs {
256 #[arg(value_name = "PATH")]
258 pub path: PathBuf,
259 #[arg(long, value_enum, default_value = "devok")]
261 pub policy: PackPolicyArg,
262 #[arg(long)]
264 pub json: bool,
265}
266
267#[derive(Subcommand, Debug)]
268pub enum PackEventsCommand {
269 List(PackEventsListArgs),
271}
272
273#[derive(Args, Debug)]
274pub struct PackEventsListArgs {
275 #[arg(value_name = "PATH")]
277 pub path: PathBuf,
278 #[arg(long, value_enum, default_value = "table")]
280 pub format: PackEventsFormatArg,
281 #[arg(long)]
283 pub verbose: bool,
284}
285
286#[derive(Args, Debug)]
287pub struct PackPlanArgs {
288 #[arg(value_name = "PATH")]
290 pub input: PathBuf,
291 #[arg(long, default_value = "tenant-local")]
293 pub tenant: String,
294 #[arg(long, default_value = "local")]
296 pub environment: String,
297 #[arg(long)]
299 pub json: bool,
300 #[arg(long)]
302 pub verbose: bool,
303}
304
305#[derive(Subcommand, Debug, Clone)]
306pub enum ComponentCommand {
307 Add(ComponentAddArgs),
309 New(ComponentNewArgs),
311 Templates(ComponentTemplatesArgs),
313 Doctor(ComponentDoctorArgs),
315 Inspect(ComponentInspectArgs),
317 Hash(ComponentHashArgs),
319 Build(ComponentBuildArgs),
321 #[command(subcommand)]
323 Flow(ComponentFlowCommand),
324 #[command(subcommand)]
326 Store(ComponentStoreCommand),
327}
328
329#[derive(Args, Debug, Clone)]
330pub struct ComponentAddArgs {
331 pub coordinate: String,
333 #[arg(long = "profile")]
335 pub profile: Option<String>,
336 #[arg(long = "intent", default_value = "dev", value_enum)]
338 pub intent: DevIntentArg,
339}
340
341#[derive(Subcommand, Debug)]
342pub enum McpCommand {
343 Doctor(McpDoctorArgs),
345}
346
347#[derive(Args, Debug)]
348pub struct McpDoctorArgs {
349 pub provider: String,
351 #[arg(long = "json")]
353 pub json: bool,
354}
355
356#[derive(Subcommand, Debug)]
357pub enum ConfigCommand {
358 Set(ConfigSetArgs),
360}
361
362#[derive(Args, Debug)]
363pub struct ConfigSetArgs {
364 pub key: String,
366 pub value: String,
368 #[arg(long = "file")]
370 pub file: Option<PathBuf>,
371}
372
373#[derive(Copy, Clone, Debug, ValueEnum)]
374pub enum PackSignArg {
375 Dev,
376 None,
377}
378
379#[derive(Copy, Clone, Debug, ValueEnum)]
380pub enum PackPolicyArg {
381 Devok,
382 Strict,
383}
384
385#[derive(Copy, Clone, Debug, ValueEnum)]
386pub enum RunPolicyArg {
387 Strict,
388 Devok,
389}
390
391#[derive(Copy, Clone, Debug, ValueEnum)]
392pub enum VerifyPolicyArg {
393 Strict,
394 Devok,
395}
396
397#[derive(Copy, Clone, Debug, ValueEnum)]
398pub enum MockSettingArg {
399 On,
400 Off,
401}
402
403#[derive(Copy, Clone, Debug, ValueEnum)]
404pub enum PackEventsFormatArg {
405 Table,
406 Json,
407 Yaml,
408}
409
410#[derive(Copy, Clone, Debug, ValueEnum)]
411pub enum ConfigFlowModeArg {
412 Default,
413 Custom,
414}
415#[derive(Copy, Clone, Debug, ValueEnum)]
416pub enum DevIntentArg {
417 Dev,
418 Runtime,
419}
420
421#[cfg(test)]
422mod tests {}