Files
Glint-Runtime/src/main.rs
2026-07-08 23:45:37 +03:00

66 lines
1.4 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
}
}
}