From 8bfe4e1f6b15e2584e3f8a61c58adf1395e1eadf Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 2 Apr 2024 04:38:56 -0400 Subject: [PATCH] fix: add back `build-wasm` temporarily --- cli/src/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/cli/src/main.rs b/cli/src/main.rs index 19df0a7a..9078eece 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -28,6 +28,7 @@ enum Commands { InitConfig(InitConfig), Generate(Generate), Build(Build), + BuildWasm(BuildWasm), Parse(Parse), Test(Test), Query(Query), @@ -115,6 +116,19 @@ struct Build { pub internal_build: bool, } +#[derive(Args)] +#[command(about = "Compile a parser to WASM", alias = "bw")] +struct BuildWasm { + #[arg( + short, + long, + help = "Run emscripten via docker even if it is installed locally" + )] + pub docker: bool, + #[arg(index = 1, num_args = 1, help = "The path to output the wasm file")] + pub path: Option, +} + #[derive(Args)] #[command(about = "Parse files", alias = "p")] struct Parse { @@ -494,6 +508,18 @@ fn run() -> Result<()> { } } + Commands::BuildWasm(wasm_options) => { + eprintln!("`build-wasm` is deprecated and will be removed in v0.24.0. You should use `build --wasm` instead"); + let grammar_path = current_dir.join(wasm_options.path.unwrap_or_default()); + wasm::compile_language_to_wasm( + &loader, + &grammar_path, + ¤t_dir, + None, + wasm_options.docker, + )?; + } + Commands::Parse(parse_options) => { let config = Config::load(parse_options.config_path)?; let output = if parse_options.output_dot {