use clap::{Parser, Subcommand, ValueEnum};
mod generate;
mod new;
mod routes;
mod templates;
#[derive(Parser)]
#[command(name = "galeon", about = "Galeon Engine CLI")]
struct Cli {
#[command(subcommand)]
command: CliCommand,
}
#[derive(Subcommand)]
enum CliCommand {
New {
name: String,
#[arg(long, default_value = "server-authoritative")]
preset: Preset,
},
Generate {
#[command(subcommand)]
target: generate::GenerateCommand,
},
Routes,
}
#[derive(Clone, ValueEnum)]
pub enum Preset {
ServerAuthoritative,
LocalFirst,
Hybrid,
}
fn main() {
let cli = Cli::parse();
match cli.command {
CliCommand::New { name, preset } => {
if let Err(e) = new::scaffold(std::path::Path::new("."), &name, &preset) {
eprintln!("error: {e}");
std::process::exit(1);
}
println!("created project `{name}`");
}
CliCommand::Generate { target } => match generate::run(target) {
Ok(path) => println!("wrote {}", path.display()),
Err(e) => {
eprintln!("error: {e}");
std::process::exit(1);
}
},
CliCommand::Routes => {
if let Err(e) = routes::run() {
eprintln!("error: {e}");
std::process::exit(1);
}
}
}
}