entity_graph/
main.rs

1//! `entity-graph` — CLI for the Prometheus entity-graph ecosystem.
2//!
3//! Subcommands:
4//!   `init`     – writes a starter `schema.json` in SDL source format
5//!   `generate` – reads an SDL JSON schema (source or IR format) and emits
6//!                TypeScript entity types + a transport-registration stub
7
8mod commands;
9mod ir;
10mod sdl_parser;
11mod templates;
12
13use anyhow::Result;
14use clap::{Parser, Subcommand};
15
16/// entity-graph CLI — scaffold schemas and generate TypeScript bindings.
17#[derive(Debug, Parser)]
18#[command(
19    name = "entity-graph",
20    version,
21    about = "Scaffold entity schemas and generate TypeScript bindings for @prometheus-ags/entity-graph-core.",
22    long_about = None,
23)]
24struct Cli {
25    #[command(subcommand)]
26    command: Commands,
27}
28
29#[derive(Debug, Subcommand)]
30enum Commands {
31    /// Write a starter `schema.json` into the target directory.
32    Init(commands::init::InitArgs),
33
34    /// Read a schema JSON and generate TypeScript entity types + transport stubs.
35    Generate(commands::generate::GenerateArgs),
36}
37
38fn main() -> Result<()> {
39    let cli = Cli::parse();
40
41    match &cli.command {
42        Commands::Init(args) => commands::init::run(args),
43        Commands::Generate(args) => commands::generate::run(args),
44    }
45}