greentic_dev/
cli.rs

1use std::{ffi::OsString, path::PathBuf};
2
3use crate::secrets_cli::SecretsCommand;
4use clap::{Args, Parser, Subcommand};
5
6#[derive(Parser, Debug)]
7#[command(name = "greentic-dev")]
8#[command(version)]
9#[command(about = "Greentic developer tooling CLI")]
10pub struct Cli {
11    #[command(subcommand)]
12    pub command: Command,
13}
14
15#[derive(Subcommand, Debug)]
16pub enum Command {
17    /// Flow passthrough (greentic-flow)
18    Flow(PassthroughArgs),
19    /// Pack passthrough (greentic-pack; pack run uses greentic-runner-cli)
20    Pack(PassthroughArgs),
21    /// Component passthrough (greentic-component)
22    Component(PassthroughArgs),
23    /// Manage greentic-dev configuration
24    #[command(subcommand)]
25    Config(ConfigCommand),
26    /// MCP tooling
27    #[command(subcommand)]
28    Mcp(McpCommand),
29    /// GUI passthrough (greentic-gui)
30    Gui(PassthroughArgs),
31    /// Secrets convenience wrappers
32    #[command(subcommand)]
33    Secrets(SecretsCommand),
34    /// Decode a CBOR file to text
35    Cbor(CborArgs),
36}
37
38#[derive(Args, Debug, Clone)]
39#[command(disable_help_flag = true)]
40pub struct PassthroughArgs {
41    /// Arguments passed directly to the underlying command
42    #[arg(
43        value_name = "ARGS",
44        trailing_var_arg = true,
45        allow_hyphen_values = true
46    )]
47    pub args: Vec<OsString>,
48}
49
50#[derive(Subcommand, Debug)]
51pub enum McpCommand {
52    /// Inspect MCP provider metadata
53    Doctor(McpDoctorArgs),
54}
55
56#[derive(Args, Debug)]
57pub struct McpDoctorArgs {
58    /// MCP provider identifier or config path
59    pub provider: String,
60    /// Emit compact JSON instead of pretty output
61    #[arg(long = "json")]
62    pub json: bool,
63}
64
65#[derive(Subcommand, Debug)]
66pub enum ConfigCommand {
67    /// Set a key in greentic-dev config (e.g. defaults.component.org)
68    Set(ConfigSetArgs),
69}
70
71#[derive(Args, Debug)]
72pub struct ConfigSetArgs {
73    /// Config key path (e.g. defaults.component.org)
74    pub key: String,
75    /// Value to assign to the key (stored as a string)
76    pub value: String,
77    /// Override config file path (default: $XDG_CONFIG_HOME/greentic-dev/config.toml)
78    #[arg(long = "file")]
79    pub file: Option<PathBuf>,
80}
81
82#[derive(Args, Debug)]
83pub struct CborArgs {
84    /// Path to the CBOR file to decode
85    #[arg(value_name = "PATH")]
86    pub path: PathBuf,
87}