dampen_cli/
lib.rs

1//! Dampen CLI - Developer Command-Line Interface
2//!
3//! This crate provides the CLI for the Dampen UI framework.
4
5#![allow(clippy::print_stderr, clippy::print_stdout)]
6
7pub mod commands;
8
9use clap::{Parser, Subcommand};
10
11/// Dampen UI Framework CLI
12#[derive(Parser)]
13#[command(name = "dampen")]
14#[command(about = "Developer CLI for Dampen UI framework", long_about = None)]
15#[command(version)]
16pub struct Cli {
17    #[command(subcommand)]
18    command: Commands,
19}
20
21#[derive(Subcommand)]
22pub enum Commands {
23    /// Build production code from .dampen files
24    Build(commands::BuildArgs),
25
26    /// Validate .dampen files without building
27    Check(commands::CheckArgs),
28
29    /// Inspect IR or generated code
30    Inspect(commands::InspectArgs),
31
32    /// Create a new Dampen project
33    New(commands::NewArgs),
34}
35
36/// CLI entry point
37pub fn run() {
38    let cli = Cli::parse();
39
40    let result = match cli.command {
41        Commands::Build(args) => commands::build_execute(&args).map_err(|e| e.to_string()),
42        Commands::Check(args) => commands::check_execute(&args).map_err(|e| e.to_string()),
43        Commands::Inspect(args) => commands::inspect_execute(&args),
44        Commands::New(args) => commands::new_execute(&args),
45    };
46
47    if let Err(e) = result {
48        eprintln!("Error: {}", e);
49        std::process::exit(1);
50    }
51}