66 lines
1.4 KiB
Rust
66 lines
1.4 KiB
Rust
mod app;
|
||
mod cli;
|
||
mod interpreter;
|
||
mod renderer;
|
||
|
||
use clap::{Parser, Subcommand};
|
||
|
||
#[derive(Debug, Clone)]
|
||
pub enum Message {
|
||
EventTriggered(String),
|
||
InputChanged(Option<String>, String),
|
||
ToggleChanged(Option<String>, bool),
|
||
SliderChanged(Option<String>, f64),
|
||
WindowScrolled(f32),
|
||
}
|
||
|
||
#[derive(Parser)]
|
||
#[command(name = "glint-runtime")]
|
||
#[command(author, version, about = "Glint runtime – compile and run .gltm/.glts files", long_about = None)]
|
||
struct Cli {
|
||
#[command(subcommand)]
|
||
command: Commands,
|
||
}
|
||
|
||
#[derive(Subcommand)]
|
||
enum Commands {
|
||
Compile {
|
||
#[arg(required = true)]
|
||
gltm_files: Vec<String>,
|
||
|
||
#[arg(short = 's', long = "style")]
|
||
glts_files: Vec<String>,
|
||
|
||
#[arg(short = 'o', long = "output")]
|
||
output: Option<String>,
|
||
},
|
||
|
||
Run {
|
||
/// Bytecode file to execute
|
||
file: String,
|
||
},
|
||
}
|
||
|
||
fn main() {
|
||
let cli = Cli::parse();
|
||
|
||
match cli.command {
|
||
Commands::Compile {
|
||
gltm_files,
|
||
glts_files,
|
||
output,
|
||
} => {
|
||
let output_path = output.unwrap_or_else(|| {
|
||
std::path::Path::new(&gltm_files[0])
|
||
.with_extension("glbc")
|
||
.to_string_lossy()
|
||
.to_string()
|
||
});
|
||
cli::compile_files(&gltm_files, &glts_files, &output_path);
|
||
}
|
||
Commands::Run { file } => {
|
||
cli::run_file(&file);
|
||
}
|
||
}
|
||
}
|