ggen_cli_lib/
lib.rs

1use clap::{CommandFactory, Parser};
2use std::path::PathBuf;
3
4use ggen_utils::app_config::AppConfig;
5use ggen_utils::error::Result;
6use ggen_utils::types::LogLevel;
7
8pub mod cmds;
9
10#[derive(Parser, Debug)]
11#[command(name = "ggen", author, about = "Graph-aware code generator", version)]
12pub struct Cli {
13    #[arg(short, long, value_name = "FILE")]
14    pub config: Option<PathBuf>,
15
16    #[arg(long, value_name = "PATH", help = "Path to ggen.toml manifest file")]
17    pub manifest_path: Option<PathBuf>,
18
19    #[arg(name = "debug", short, long = "debug", value_name = "DEBUG")]
20    pub debug: Option<bool>,
21
22    #[arg(
23        name = "log_level",
24        short,
25        long = "log-level",
26        value_name = "LOG_LEVEL"
27    )]
28    pub log_level: Option<LogLevel>,
29
30    #[clap(subcommand)]
31    pub command: cmds::Commands,
32}
33
34pub async fn cli_match() -> Result<()> {
35    let cli = Cli::parse();
36
37    AppConfig::merge_config(cli.config.as_deref())?;
38    let app = Cli::command();
39    let matches = app.get_matches();
40    AppConfig::merge_args(&matches)?;
41
42    // For now, skip ggen.toml loading until we implement the methods
43    cli.command.run().await
44}