slint/tools/viewer/main.rs
Olivier Goffart a8f02df642 Refactor the viewer into a binary, and an interpreter crate
The interpreter can be used from other crates such as the test or the JS for example
2020-06-02 17:05:48 +02:00

22 lines
583 B
Rust

use structopt::StructOpt;
#[derive(StructOpt)]
struct Cli {
#[structopt(name = "path to .60 file", parse(from_os_str))]
path: std::path::PathBuf,
}
fn main() -> std::io::Result<()> {
let args = Cli::from_args();
let source = std::fs::read_to_string(&args.path)?;
let c = match interpreter::load(source.as_str(), &args.path) {
Ok(c) => c,
Err(diag) => {
diag.print(source);
std::process::exit(-1);
}
};
interpreter::instentiate(c, |x| gl::sixtyfps_runtime_run_component_with_gl_renderer(x));
Ok(())
}