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,
#[arg(long, global = true)]
pub verbose: bool,
#[arg(long, global = true)]
pub quiet: bool,
}
#[derive(Subcommand)]
pub enum Command {
Init(init::InitArgs),
Build(build::BuildArgs),
Check(check::CheckArgs),
Watch(watch::WatchArgs),
Dev(dev::DevArgs),
Format(format::FormatArgs),
Preview(preview::PreviewArgs),
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(),
}
}