Skip to main content

van_cli/
lib.rs

1mod cmd;
2
3use clap::{Parser, Subcommand};
4
5#[derive(Parser)]
6#[command(name = "van", version, about = "Van - Vue-like template engine toolchain")]
7struct Cli {
8    #[command(subcommand)]
9    command: Commands,
10}
11
12#[derive(Subcommand)]
13enum Commands {
14    /// Create a new Van project
15    Init {
16        /// Project name (optional, will prompt if not provided)
17        name: Option<String>,
18    },
19    /// Start development server
20    Dev,
21    /// Generate static HTML pages
22    Generate,
23}
24
25pub async fn run() {
26    let cli = Cli::parse();
27
28    let result = match cli.command {
29        Commands::Init { name } => cmd::init::run(name),
30        Commands::Dev => cmd::dev::run().await,
31        Commands::Generate => cmd::generate::run(),
32    };
33
34    if let Err(e) = result {
35        eprintln!("Error: {e:#}");
36        std::process::exit(1);
37    }
38}