diff --git a/Cargo.lock b/Cargo.lock index 0f1322d..5e050c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "ansi_term" version = "0.11.0" @@ -49,7 +51,7 @@ dependencies = [ [[package]] name = "gluac-rs" -version = "0.1.3" +version = "0.1.4" dependencies = [ "clap", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 19f93b3..512ba77 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gluac-rs" -version = "0.1.3" +version = "0.1.4" authors = ["William Venner "] edition = "2018" repository = "https://github.com/WilliamVenner/gluac-rs" diff --git a/src/bin/gluac.rs b/src/bin/gluac.rs index 40eb041..f29a21c 100644 --- a/src/bin/gluac.rs +++ b/src/bin/gluac.rs @@ -28,6 +28,14 @@ fn main() { .required(true) .raw(true), ) + .arg( + clap::Arg::with_name("output") + .short("o") + .help("Output file path") + .takes_value(true) + .multiple(false) + .required(false) + ) .get_matches(); let strip_debug = matches.args.get("strip").is_some(); @@ -50,7 +58,11 @@ fn main() { unreachable!(); }; - let mut stdout = std::io::stdout(); - stdout.write_all(&bytecode).expect("Failed to write to stdout"); - stdout.flush().expect("Failed to write to stdout"); + if let Some(output) = matches.args.get("output") { + std::fs::write(output.vals[0].as_os_str(), &bytecode).expect("Failed to write to output file"); + } else { + let mut stdout = std::io::stdout(); + stdout.write_all(&bytecode).expect("Failed to write to stdout"); + stdout.flush().expect("Failed to write to stdout"); + } }