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    /// Read config from file
40    #[arg(long, value_name = "FILE")]
41    pub config: Option<String>,
42
43    #[command(subcommand)]
44    pub command: Option<Command>,
45}
46
47/// Subcommands
48#[derive(clap::Subcommand, Debug)]
49pub enum Command {
50    /// Update an existing project to the latest template
51    Update {
52        /// Show changes without applying
53        #[arg(long)]
54        dry_run: bool,
55    },
56}
57
58/// Parse CLI arguments.
59pub fn parse() -> Args {
60    Args::parse()
61}