diff --git a/CHANGELOG.md b/CHANGELOG.md index 24d0a57f3ee..41a4c269131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#968](https://github.com/wasmerio/wasmer/pull/968) Added `--invoke` option to the command - [#960](https://github.com/wasmerio/wasmer/pull/960) Fix `runtime-c-api` header files when compiled by clang. - [#925](https://github.com/wasmerio/wasmer/pull/925) Host functions can be closures with a captured environment. - [#917](https://github.com/wasmerio/wasmer/pull/917) Host functions (aka imported functions) may not have `&mut vm::Ctx` as first argument, i.e. the presence of the `&mut vm::Ctx` argument is optional. diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 6195e60a612..7af5df3e258 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -132,6 +132,10 @@ struct Run { )] backend: Backend, + /// Invoke a specified function + #[structopt(long = "invoke", short = "i")] + invoke: Option, + /// Emscripten symbol map #[structopt(long = "em-symbol-map", parse(from_os_str), group = "emscripten")] em_symbol_map: Option, @@ -683,8 +687,12 @@ fn execute_wasm(options: &Run) -> Result<(), String> { args.push(Value::I32(x)); } + let invoke_fn = match options.invoke.as_ref() { + Some(fun) => fun, + _ => "main", + }; instance - .dyn_func("main") + .dyn_func(&invoke_fn) .map_err(|e| format!("{:?}", e))? .call(&args) .map_err(|e| format!("{:?}", e))?;