1use std::path::PathBuf;
2
3use clap::{Args, Parser, Subcommand, ValueEnum};
4use greentic_component::cmd::{
5 build::BuildArgs as ComponentBuildArgs, doctor::DoctorArgs as ComponentDoctorArgs,
6 flow::FlowCommand as ComponentFlowCommand, hash::HashArgs as ComponentHashArgs,
7 inspect::InspectArgs as ComponentInspectArgs, new::NewArgs as ComponentNewArgs,
8 store::StoreCommand as ComponentStoreCommand,
9 templates::TemplatesArgs as ComponentTemplatesArgs,
10};
11
12#[derive(Parser, Debug)]
13#[command(name = "greentic-dev")]
14#[command(version)]
15#[command(about = "Greentic developer tooling CLI")]
16pub struct Cli {
17 #[command(subcommand)]
18 pub command: Command,
19}
20
21#[derive(Subcommand, Debug)]
22pub enum Command {
23 #[command(subcommand)]
25 Flow(FlowCommand),
26 #[command(subcommand)]
28 Pack(PackCommand),
29 #[command(subcommand)]
31 Component(ComponentCommand),
32 #[command(subcommand)]
34 Config(ConfigCommand),
35 #[command(subcommand)]
37 Mcp(McpCommand),
38}
39
40#[derive(Subcommand, Debug)]
41pub enum FlowCommand {
42 Validate(FlowValidateArgs),
44 AddStep(FlowAddStepArgs),
46}
47
48#[derive(Args, Debug)]
49pub struct FlowValidateArgs {
50 #[arg(short = 'f', long = "file")]
52 pub file: PathBuf,
53 #[arg(long = "json")]
55 pub json: bool,
56}
57
58#[derive(Args, Debug)]
59pub struct FlowAddStepArgs {
60 #[arg(long = "manifest")]
62 pub manifest: Option<PathBuf>,
63 #[arg(long = "flow", default_value = "default")]
65 pub flow: String,
66 pub flow_id: String,
68 #[arg(long = "coordinate")]
70 pub coordinate: Option<String>,
71 #[arg(long = "profile")]
73 pub profile: Option<String>,
74 #[arg(long = "mode", value_enum)]
76 pub mode: Option<ConfigFlowModeArg>,
77 #[arg(long = "after")]
79 pub after: Option<String>,
80}
81
82#[derive(Subcommand, Debug)]
83pub enum PackCommand {
84 Build(PackcArgs),
86 Lint(PackcArgs),
88 New(PackcArgs),
90 Sign(PackcArgs),
92 Verify(PackcArgs),
94 Inspect(PackInspectArgs),
96 Plan(PackPlanArgs),
98 #[command(subcommand)]
100 Events(PackEventsCommand),
101 Run(PackRunArgs),
103 Init(PackInitArgs),
105}
106
107#[derive(Args, Debug)]
108pub struct PackRunArgs {
109 #[arg(short = 'p', long = "pack")]
111 pub pack: PathBuf,
112 #[arg(long = "entry")]
114 pub entry: Option<String>,
115 #[arg(long = "input")]
117 pub input: Option<String>,
118 #[arg(long = "json")]
120 pub json: bool,
121 #[arg(long = "offline")]
123 pub offline: bool,
124 #[arg(long = "mock-exec", hide = true)]
126 pub mock_exec: bool,
127 #[arg(long = "allow-external", hide = true)]
129 pub allow_external: bool,
130 #[arg(long = "mock-external", hide = true)]
132 pub mock_external: bool,
133 #[arg(long = "mock-external-payload", hide = true)]
135 pub mock_external_payload: Option<PathBuf>,
136 #[arg(long = "secrets-env-prefix", hide = true)]
138 pub secrets_env_prefix: Option<String>,
139 #[arg(long = "policy", default_value = "devok", value_enum)]
141 pub policy: RunPolicyArg,
142 #[arg(long = "otlp")]
144 pub otlp: Option<String>,
145 #[arg(long = "allow")]
147 pub allow: Option<String>,
148 #[arg(long = "mocks", default_value = "on", value_enum)]
150 pub mocks: MockSettingArg,
151 #[arg(long = "artifacts")]
153 pub artifacts: Option<PathBuf>,
154}
155
156#[derive(Args, Debug)]
157pub struct PackInitArgs {
158 pub from: String,
160 #[arg(long = "profile")]
162 pub profile: Option<String>,
163}
164
165#[derive(Args, Debug, Clone, Default)]
166#[command(disable_help_flag = true)]
167pub struct PackcArgs {
168 #[arg(
170 value_name = "ARGS",
171 trailing_var_arg = true,
172 allow_hyphen_values = true
173 )]
174 pub passthrough: Vec<String>,
175}
176
177#[derive(Args, Debug)]
178pub struct PackInspectArgs {
179 #[arg(value_name = "PATH")]
181 pub path: PathBuf,
182 #[arg(long, value_enum, default_value = "devok")]
184 pub policy: PackPolicyArg,
185 #[arg(long)]
187 pub json: bool,
188}
189
190#[derive(Subcommand, Debug)]
191pub enum PackEventsCommand {
192 List(PackEventsListArgs),
194}
195
196#[derive(Args, Debug)]
197pub struct PackEventsListArgs {
198 #[arg(value_name = "PATH")]
200 pub path: PathBuf,
201 #[arg(long, value_enum, default_value = "table")]
203 pub format: PackEventsFormatArg,
204 #[arg(long)]
206 pub verbose: bool,
207}
208
209#[derive(Args, Debug)]
210pub struct PackPlanArgs {
211 #[arg(value_name = "PATH")]
213 pub input: PathBuf,
214 #[arg(long, default_value = "tenant-local")]
216 pub tenant: String,
217 #[arg(long, default_value = "local")]
219 pub environment: String,
220 #[arg(long)]
222 pub json: bool,
223 #[arg(long)]
225 pub verbose: bool,
226}
227
228#[derive(Subcommand, Debug, Clone)]
229pub enum ComponentCommand {
230 Add(ComponentAddArgs),
232 New(ComponentNewArgs),
234 Templates(ComponentTemplatesArgs),
236 Doctor(ComponentDoctorArgs),
238 Inspect(ComponentInspectArgs),
240 Hash(ComponentHashArgs),
242 Build(ComponentBuildArgs),
244 #[command(subcommand)]
246 Flow(ComponentFlowCommand),
247 #[command(subcommand)]
249 Store(ComponentStoreCommand),
250}
251
252#[derive(Args, Debug, Clone)]
253pub struct ComponentAddArgs {
254 pub coordinate: String,
256 #[arg(long = "profile")]
258 pub profile: Option<String>,
259 #[arg(long = "intent", default_value = "dev", value_enum)]
261 pub intent: DevIntentArg,
262}
263
264#[derive(Subcommand, Debug)]
265pub enum McpCommand {
266 Doctor(McpDoctorArgs),
268}
269
270#[derive(Args, Debug)]
271pub struct McpDoctorArgs {
272 pub provider: String,
274 #[arg(long = "json")]
276 pub json: bool,
277}
278
279#[derive(Subcommand, Debug)]
280pub enum ConfigCommand {
281 Set(ConfigSetArgs),
283}
284
285#[derive(Args, Debug)]
286pub struct ConfigSetArgs {
287 pub key: String,
289 pub value: String,
291 #[arg(long = "file")]
293 pub file: Option<PathBuf>,
294}
295
296#[derive(Copy, Clone, Debug, ValueEnum)]
297pub enum PackSignArg {
298 Dev,
299 None,
300}
301
302#[derive(Copy, Clone, Debug, ValueEnum)]
303pub enum PackPolicyArg {
304 Devok,
305 Strict,
306}
307
308#[derive(Copy, Clone, Debug, ValueEnum)]
309pub enum RunPolicyArg {
310 Strict,
311 Devok,
312}
313
314#[derive(Copy, Clone, Debug, ValueEnum)]
315pub enum VerifyPolicyArg {
316 Strict,
317 Devok,
318}
319
320#[derive(Copy, Clone, Debug, ValueEnum)]
321pub enum MockSettingArg {
322 On,
323 Off,
324}
325
326#[derive(Copy, Clone, Debug, ValueEnum)]
327pub enum PackEventsFormatArg {
328 Table,
329 Json,
330 Yaml,
331}
332
333#[derive(Copy, Clone, Debug, ValueEnum)]
334pub enum ConfigFlowModeArg {
335 Default,
336 Custom,
337}
338#[derive(Copy, Clone, Debug, ValueEnum)]
339pub enum DevIntentArg {
340 Dev,
341 Runtime,
342}
343
344#[cfg(test)]
345mod tests {}