fix: add back build-wasm temporarily

This commit is contained in:
Amaan Qureshi 2024-04-02 04:38:56 -04:00
parent 33de5ef849
commit 8bfe4e1f6b

View file

@ -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<String>,
}
#[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,
&current_dir,
None,
wasm_options.docker,
)?;
}
Commands::Parse(parse_options) => {
let config = Config::load(parse_options.config_path)?;
let output = if parse_options.output_dot {