Generate TypeScript by default instead of JS

This is what's needed in the immediate future anyway, so let's do that!
This commit is contained in:
Alex Crichton
2017-12-19 19:06:48 -08:00
parent 34e4cfa95d
commit 85cdb51719
10 changed files with 1011 additions and 616 deletions

View File

@ -16,14 +16,14 @@ Usage:
Options:
-h --help Show this screen.
--output-js FILE Output JS file
--output-ts FILE Output TypeScript file
--output-wasm FILE Output WASM file
--nodejs Generate output for node.js, not the browser
";
#[derive(Debug, Deserialize)]
struct Args {
flag_output_js: Option<PathBuf>,
flag_output_ts: Option<PathBuf>,
flag_output_wasm: Option<PathBuf>,
flag_nodejs: bool,
arg_input: PathBuf,
@ -38,10 +38,10 @@ fn main() {
b.input_path(&args.arg_input);
b.nodejs(args.flag_nodejs);
let ret = b.generate().expect("failed to generate bindings");
if let Some(ref js) = args.flag_output_js {
ret.write_js_to(js).expect("failed to write JS output file");
if let Some(ref ts) = args.flag_output_ts {
ret.write_ts_to(ts).expect("failed to write TypeScript output file");
} else {
println!("{}", ret.generate_js());
println!("{}", ret.generate_ts());
}
if let Some(ref wasm) = args.flag_output_wasm {
ret.write_wasm_to(wasm).expect("failed to write wasm output file");