diff --git a/CHANGELOG.md b/CHANGELOG.md index c658e024d3a..c7b0088dc52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#992](https://github.com/wasmerio/wasmer/pull/992) Updates WAPM version to 0.4.1, fix arguments issue introduced in #990 - [#990](https://github.com/wasmerio/wasmer/pull/990) Default wasmer CLI to `run`. Wasmer will now attempt to parse unrecognized command line options as if they were applied to the run command: `wasmer mywasm.wasm --dir=.` now works! - [#987](https://github.com/wasmerio/wasmer/pull/987) Fix `runtime-c-api` header files when compiled by gnuc. diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 26afcc03947..36e0100d671 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -18,7 +18,7 @@ use std::process::exit; use std::str::FromStr; use std::collections::HashMap; -use structopt::StructOpt; +use structopt::{clap, StructOpt}; use wasmer::*; use wasmer_clif_backend::CraneliftCompiler; @@ -848,8 +848,19 @@ fn get_compiler_by_backend(backend: Backend) -> Option> { } fn main() { - let options = CLIOptions::from_iter_safe(env::args()) - .unwrap_or_else(|_| CLIOptions::Run(Run::from_args())); + // We try to run wasmer with the normal arguments. + // Eg. `wasmer ` + // In case that fails, we fallback trying the Run subcommand directly. + // Eg. `wasmer myfile.wasm --dir=.` + let options = CLIOptions::from_iter_safe(env::args()).unwrap_or_else(|e| { + match e.kind { + // This fixes a issue that: + // 1. Shows the version twice when doing `wasmer -V` + // 2. Shows the run help (instead of normal help) when doing `wasmer --help` + clap::ErrorKind::VersionDisplayed | clap::ErrorKind::HelpDisplayed => e.exit(), + _ => CLIOptions::Run(Run::from_args()), + } + }); match options { CLIOptions::Run(options) => run(options), #[cfg(not(target_os = "windows"))] diff --git a/wapm-cli b/wapm-cli index c2da5cda3b8..3562d6dda52 160000 --- a/wapm-cli +++ b/wapm-cli @@ -1 +1 @@ -Subproject commit c2da5cda3b8f9cf7dcea144f8cabdf342f38a0bf +Subproject commit 3562d6dda52df526e6e1917dd33bb2454917ab9c