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    /// Add UI windows or other components
24    Add(commands::AddArgs),
25
26    /// Build production code with codegen mode
27    Build(commands::BuildArgs),
28
29    /// Validate .dampen files without building
30    Check(commands::CheckArgs),
31
32    /// Inspect IR or generated code
33    Inspect(commands::InspectArgs),
34
35    /// Create a new Dampen project
36    New(commands::NewArgs),
37
38    /// Build optimized production binary (release mode with codegen)
39    Release(commands::ReleaseArgs),
40
41    /// Run application in development mode with interpreted execution
42    Run(commands::RunArgs),
43
44    /// Run tests for the Dampen project
45    Test(commands::TestArgs),
46}
47
48/// CLI entry point
49pub fn run() {
50    let cli = Cli::parse();
51
52    let result = match cli.command {
53        Commands::Add(args) => commands::add_execute(&args),
54        Commands::Build(args) => commands::build_execute(&args).map_err(|e| e.to_string()),
55        Commands::Check(args) => commands::check_execute(&args).map_err(|e| e.to_string()),
56        Commands::Inspect(args) => commands::inspect_execute(&args),
57        Commands::New(args) => commands::new_execute(&args),
58        Commands::Release(args) => commands::release_execute(&args),
59        Commands::Run(args) => commands::run_execute(&args).map_err(|e| e.to_string()),
60        Commands::Test(args) => commands::test_execute(&args),
61    };
62
63    if let Err(e) = result {
64        eprintln!("Error: {}", e);
65        std::process::exit(1);
66    }
67}