orbiton/
main.rs

1// Main entry point for the orbiton CLI tool
2
3use clap::{Parser, Subcommand};
4use console::style;
5use log::info;
6
7mod commands;
8mod config;
9mod dev_server;
10mod hmr;
11mod hmr_inject;
12#[cfg(test)]
13mod integration_tests;
14mod maintenance;
15mod templates;
16mod test_hmr_module;
17mod utils;
18
19/// Version of the orbiton CLI
20const VERSION: &str = env!("CARGO_PKG_VERSION");
21
22#[derive(Parser)]
23#[command(name = "orbiton")]
24#[command(author = "Orbit Framework Team")]
25#[command(version = VERSION)]
26#[command(about = "CLI tooling for the Orbit UI framework", long_about = None)]
27struct Cli {
28    /// Verbose output
29    #[arg(short, long, global = true)]
30    verbose: bool,
31
32    #[command(subcommand)]
33    command: Commands,
34}
35
36#[derive(Subcommand)]
37enum Commands {
38    /// Create a new Orbit project
39    New(commands::new::NewArgs),
40
41    /// Start the development server
42    Dev(commands::dev::DevArgs),
43
44    /// Build the project
45    Build(commands::build::BuildArgs),
46
47    /// Configure the renderer
48    Renderer(commands::renderer::RendererArgs),
49    /// Run tests for the project
50    Test(commands::test::TestCommand),
51
52    /// Manage configuration
53    Config(commands::config::ConfigArgs),
54
55    /// Perform maintenance operations
56    Maintenance(commands::maintenance::MaintenanceArgs),
57}
58
59fn main() -> anyhow::Result<()> {
60    // Parse the command line arguments
61    let cli = Cli::parse();
62
63    // Initialize logging
64    if cli.verbose {
65        env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug")).init();
66    } else {
67        env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
68    }
69
70    // Print welcome message
71    println!("{} v{}", style("orbiton").bold().green(), VERSION);
72
73    // Execute the appropriate command
74    match cli.command {
75        Commands::New(args) => {
76            commands::new::execute(args)?;
77        }
78        Commands::Dev(args) => {
79            commands::dev::execute(args)?;
80        }
81        Commands::Build(args) => {
82            commands::build::execute(args)?;
83        }
84        Commands::Renderer(args) => {
85            commands::renderer::execute(args)?;
86        }
87        Commands::Test(args) => {
88            args.execute()?;
89        }
90        Commands::Config(args) => {
91            commands::config::execute(args)?;
92        }
93        Commands::Maintenance(args) => {
94            commands::maintenance::execute(args)?;
95        }
96    }
97    info!("Command completed successfully");
98    Ok(())
99}
100
101/// Print version information and available commands
102#[allow(dead_code)] // Utility function for help/documentation
103pub fn show_help_info() {
104    println!("Available commands:");
105    println!("  new         - Create a new Orbit project");
106    println!("  dev         - Start development server");
107    println!("  build       - Build project");
108    println!("  test        - Run tests");
109    println!("  config      - Manage configuration");
110    println!("  maintenance - Perform maintenance operations");
111}