#![allow(dead_code)]
mod cli;
mod lexer;
mod parser;
mod codegen;
mod runtime;
mod themes;
mod config;
mod error;
mod linter;
mod template;
use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser)]
#[command(name = "wf")]
#[command(about = "WebFluent — Build SPAs with a web-first language", long_about = None)]
#[command(version)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Init {
name: String,
#[arg(short, long, default_value = "spa")]
template: String,
},
Build {
#[arg(short, long, default_value = ".")]
dir: PathBuf,
},
Serve {
#[arg(short, long, default_value = ".")]
dir: PathBuf,
},
Generate {
kind: String,
name: String,
#[arg(short, long, default_value = ".")]
dir: PathBuf,
},
Render {
template: PathBuf,
#[arg(long)]
data: Option<PathBuf>,
#[arg(short, long, default_value = "html")]
format: String,
#[arg(short, long)]
output: Option<PathBuf>,
#[arg(long, default_value = "default")]
theme: String,
},
}
fn main() {
let cli = Cli::parse();
let result = match cli.command {
Commands::Init { name, template } => cli::init::run_init(&name, &template),
Commands::Build { dir } => cli::build::run_build(&dir),
Commands::Serve { dir } => cli::serve::run_serve(&dir),
Commands::Generate { kind, name, dir } => cli::generate::run_generate(&kind, &name, &dir),
Commands::Render { template: tpl, data, format, output, theme } => {
cli::render::run_render(&tpl, data.as_deref(), &format, output.as_deref(), &theme)
}
};
if let Err(e) = result {
eprintln!("{}", e);
std::process::exit(1);
}
}