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 with codegen mode
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    /// Build optimized production binary (release mode with codegen)
36    Release(commands::ReleaseArgs),
37
38    /// Run application in development mode with interpreted execution
39    Run(commands::RunArgs),
40
41    /// Run tests for the Dampen project
42    Test(commands::TestArgs),
43}
44
45/// CLI entry point
46pub fn run() {
47    let cli = Cli::parse();
48
49    let result = match cli.command {
50        Commands::Build(args) => commands::build_execute(&args).map_err(|e| e.to_string()),
51        Commands::Check(args) => commands::check_execute(&args).map_err(|e| e.to_string()),
52        Commands::Inspect(args) => commands::inspect_execute(&args),
53        Commands::New(args) => commands::new_execute(&args),
54        Commands::Release(args) => commands::release_execute(&args),
55        Commands::Run(args) => commands::run_execute(&args).map_err(|e| e.to_string()),
56        Commands::Test(args) => commands::test_execute(&args),
57    };
58
59    if let Err(e) = result {
60        eprintln!("Error: {}", e);
61        std::process::exit(1);
62    }
63}