nativ 0.2.0

Nativ CLI — compile .nativ DSL to real SwiftUI and Jetpack Compose
mod build;
mod check;
mod dev;
mod format;
mod init;
mod preview;
mod version;
mod watch;

use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(
    name = "nativ",
    about = "Compile-time native UI compiler: .nativ -> SwiftUI + Jetpack Compose",
    version = env!("CARGO_PKG_VERSION"),
    after_help = "Learn more: https://nativ.dev"
)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Command,

    /// Show verbose output
    #[arg(long, global = true)]
    pub verbose: bool,

    /// Quiet mode (errors only)
    #[arg(long, global = true)]
    pub quiet: bool,
}

#[derive(Subcommand)]
pub enum Command {
    /// Create a new Nativ project
    Init(init::InitArgs),

    /// Compile .nativ files -> .swift/.kt
    Build(build::BuildArgs),

    /// Validate .nativ files without generating code
    Check(check::CheckArgs),

    /// Watch for changes and rebuild automatically
    Watch(watch::WatchArgs),

    /// Dev server: watch for changes and classify edit type
    Dev(dev::DevArgs),

    /// Format .nativ files
    Format(format::FormatArgs),

    /// Open a live preview in the browser
    Preview(preview::PreviewArgs),

    /// Show Nativ version information
    Version,
}

pub fn run(cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
    match cli.command {
        Command::Init(args) => init::run(args, cli.verbose),
        Command::Build(args) => build::run(args, cli.verbose, cli.quiet),
        Command::Check(args) => check::run(args, cli.verbose),
        Command::Watch(args) => watch::run(args, cli.verbose),
        Command::Dev(args) => dev::run(args, cli.verbose),
        Command::Format(args) => format::run(args, cli.verbose),
        Command::Preview(args) => preview::run(args),
        Command::Version => version::run(),
    }
}