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 pub flow_id: String,
62 #[arg(long = "coordinate")]
64 pub coordinate: Option<String>,
65 #[arg(long = "profile")]
67 pub profile: Option<String>,
68 #[arg(long = "mode", value_enum)]
70 pub mode: Option<ConfigFlowModeArg>,
71 #[arg(long = "after")]
73 pub after: Option<String>,
74}
75
76#[derive(Subcommand, Debug)]
77pub enum PackCommand {
78 Build(PackcArgs),
80 Lint(PackcArgs),
82 New(PackcArgs),
84 Sign(PackcArgs),
86 Verify(PackcArgs),
88 Inspect(PackInspectArgs),
90 Plan(PackPlanArgs),
92 #[command(subcommand)]
94 Events(PackEventsCommand),
95 Run(PackRunArgs),
97 Init(PackInitArgs),
99}
100
101#[derive(Args, Debug)]
102pub struct PackRunArgs {
103 #[arg(short = 'p', long = "pack")]
105 pub pack: PathBuf,
106 #[arg(long = "entry")]
108 pub entry: Option<String>,
109 #[arg(long = "input")]
111 pub input: Option<String>,
112 #[arg(long = "policy", default_value = "devok", value_enum)]
114 pub policy: RunPolicyArg,
115 #[arg(long = "otlp")]
117 pub otlp: Option<String>,
118 #[arg(long = "allow")]
120 pub allow: Option<String>,
121 #[arg(long = "mocks", default_value = "on", value_enum)]
123 pub mocks: MockSettingArg,
124 #[arg(long = "artifacts")]
126 pub artifacts: Option<PathBuf>,
127}
128
129#[derive(Args, Debug)]
130pub struct PackInitArgs {
131 pub from: String,
133 #[arg(long = "profile")]
135 pub profile: Option<String>,
136}
137
138#[derive(Args, Debug, Clone, Default)]
139#[command(disable_help_flag = true)]
140pub struct PackcArgs {
141 #[arg(
143 value_name = "ARGS",
144 trailing_var_arg = true,
145 allow_hyphen_values = true
146 )]
147 pub passthrough: Vec<String>,
148}
149
150#[derive(Args, Debug)]
151pub struct PackInspectArgs {
152 #[arg(value_name = "PATH")]
154 pub path: PathBuf,
155 #[arg(long, value_enum, default_value = "devok")]
157 pub policy: PackPolicyArg,
158 #[arg(long)]
160 pub json: bool,
161}
162
163#[derive(Subcommand, Debug)]
164pub enum PackEventsCommand {
165 List(PackEventsListArgs),
167}
168
169#[derive(Args, Debug)]
170pub struct PackEventsListArgs {
171 #[arg(value_name = "PATH")]
173 pub path: PathBuf,
174 #[arg(long, value_enum, default_value = "table")]
176 pub format: PackEventsFormatArg,
177 #[arg(long)]
179 pub verbose: bool,
180}
181
182#[derive(Args, Debug)]
183pub struct PackPlanArgs {
184 #[arg(value_name = "PATH")]
186 pub input: PathBuf,
187 #[arg(long, default_value = "tenant-local")]
189 pub tenant: String,
190 #[arg(long, default_value = "local")]
192 pub environment: String,
193 #[arg(long)]
195 pub json: bool,
196 #[arg(long)]
198 pub verbose: bool,
199}
200
201#[derive(Subcommand, Debug, Clone)]
202pub enum ComponentCommand {
203 Add(ComponentAddArgs),
205 New(ComponentNewArgs),
207 Templates(ComponentTemplatesArgs),
209 Doctor(ComponentDoctorArgs),
211 Inspect(ComponentInspectArgs),
213 Hash(ComponentHashArgs),
215 Build(ComponentBuildArgs),
217 #[command(subcommand)]
219 Flow(ComponentFlowCommand),
220 #[command(subcommand)]
222 Store(ComponentStoreCommand),
223}
224
225#[derive(Args, Debug, Clone)]
226pub struct ComponentAddArgs {
227 pub coordinate: String,
229 #[arg(long = "profile")]
231 pub profile: Option<String>,
232 #[arg(long = "intent", default_value = "dev", value_enum)]
234 pub intent: DevIntentArg,
235}
236
237#[derive(Subcommand, Debug)]
238pub enum McpCommand {
239 Doctor(McpDoctorArgs),
241}
242
243#[derive(Args, Debug)]
244pub struct McpDoctorArgs {
245 pub provider: String,
247 #[arg(long = "json")]
249 pub json: bool,
250}
251
252#[derive(Subcommand, Debug)]
253pub enum ConfigCommand {
254 Set(ConfigSetArgs),
256}
257
258#[derive(Args, Debug)]
259pub struct ConfigSetArgs {
260 pub key: String,
262 pub value: String,
264 #[arg(long = "file")]
266 pub file: Option<PathBuf>,
267}
268
269#[derive(Copy, Clone, Debug, ValueEnum)]
270pub enum PackSignArg {
271 Dev,
272 None,
273}
274
275#[derive(Copy, Clone, Debug, ValueEnum)]
276pub enum PackPolicyArg {
277 Devok,
278 Strict,
279}
280
281#[derive(Copy, Clone, Debug, ValueEnum)]
282pub enum RunPolicyArg {
283 Strict,
284 Devok,
285}
286
287#[derive(Copy, Clone, Debug, ValueEnum)]
288pub enum VerifyPolicyArg {
289 Strict,
290 Devok,
291}
292
293#[derive(Copy, Clone, Debug, ValueEnum)]
294pub enum MockSettingArg {
295 On,
296 Off,
297}
298
299#[derive(Copy, Clone, Debug, ValueEnum)]
300pub enum PackEventsFormatArg {
301 Table,
302 Json,
303 Yaml,
304}
305
306#[derive(Copy, Clone, Debug, ValueEnum)]
307pub enum ConfigFlowModeArg {
308 Default,
309 Custom,
310}
311#[derive(Copy, Clone, Debug, ValueEnum)]
312pub enum DevIntentArg {
313 Dev,
314 Runtime,
315}
316
317#[cfg(test)]
318mod tests {}