Skip to main content

create_grafana_plugin/
cli.rs

1use clap::Parser;
2
3/// CLI tool to scaffold production-ready Grafana plugin projects.
4#[derive(Parser, Debug)]
5#[command(name = "create-grafana-plugin", version, about)]
6pub struct Args {
7    /// Plugin name (kebab-case)
8    #[arg(long)]
9    pub name: Option<String>,
10
11    /// Plugin description
12    #[arg(long)]
13    pub description: Option<String>,
14
15    /// Author name
16    #[arg(long)]
17    pub author: Option<String>,
18
19    /// Grafana organization name
20    #[arg(long)]
21    pub org: Option<String>,
22
23    /// Plugin type: panel, datasource, app
24    #[arg(long, value_name = "TYPE")]
25    pub r#type: Option<String>,
26
27    /// Include Rust WASM engine
28    #[arg(long)]
29    pub wasm: bool,
30
31    /// Include Docker dev environment
32    #[arg(long)]
33    pub docker: bool,
34
35    /// Include mock data generator (requires --docker)
36    #[arg(long)]
37    pub mock: bool,
38
39    /// Port offset for Docker services (e.g. 100 → Grafana on 3100)
40    #[arg(long)]
41    pub port_offset: Option<u16>,
42
43    /// Read config from file
44    #[arg(long, value_name = "FILE")]
45    pub config: Option<String>,
46
47    #[command(subcommand)]
48    pub command: Option<Command>,
49}
50
51/// Subcommands
52#[derive(clap::Subcommand, Debug)]
53pub enum Command {
54    /// Update an existing project to the latest template
55    Update {
56        /// Show changes without applying
57        #[arg(long)]
58        dry_run: bool,
59    },
60}
61
62/// Parse CLI arguments.
63pub fn parse() -> Args {
64    Args::parse()
65}