use clap::{Parser, Subcommand};
use std::path::PathBuf;
mod commands;
mod config;
mod platform;
mod templating;
#[derive(Parser)]
#[command(name = "jffi")]
#[command(about = "JFFI - Cross-platform app framework with Rust + native UIs", long_about = None)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
New {
name: String,
#[arg(short, long)]
platforms: Option<String>,
#[arg(short, long)]
template: Option<String>,
#[arg(short = 'd', long)]
path: Option<PathBuf>,
},
Build {
#[arg(short, long)]
platform: Option<String>,
#[arg(short, long)]
all: bool,
#[arg(short, long)]
release: bool,
#[arg(short, long)]
device: bool,
#[arg(long)]
deploy: bool,
},
Run {
#[arg(short, long, default_value = "ios")]
platform: String,
#[arg(short, long)]
device: bool,
},
Dev {
#[arg(short, long, default_value = "ios")]
platform: String,
},
Add {
platform: String,
},
Remove {
platform: String,
},
}
fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
match cli.command {
Commands::New { name, platforms, template, path } => {
commands::new::create_project(&name, platforms.as_deref(), template.as_deref(), path)?;
}
Commands::Build { platform, all, release, device, deploy } => {
commands::build::build_project(platform, all, release, device, deploy)?;
}
Commands::Run { platform, device } => {
commands::run::run_project(&platform, device)?;
}
Commands::Dev { platform } => {
commands::dev::watch_project(&platform)?;
}
Commands::Add { platform } => {
commands::add::add_platform(&platform)?;
}
Commands::Remove { platform } => {
commands::remove::remove_platform(&platform)?;
}
}
Ok(())
}