Skip to content

Commit

Permalink
Add -o flag to binary
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamVenner committed Jul 11, 2024
1 parent 5fe0298 commit 25badb3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gluac-rs"
version = "0.1.3"
version = "0.1.4"
authors = ["William Venner <william@venner.io>"]
edition = "2018"
repository = "https://github.com/WilliamVenner/gluac-rs"
Expand Down
18 changes: 15 additions & 3 deletions src/bin/gluac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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");
}
}

0 comments on commit 25badb3

Please sign in to comment.