From 70197c2e07d6df2179676bba0e977dcd03e66a2b Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 16:38:50 -0800 Subject: [PATCH 1/6] Update wapm-cli to latest version --- wapm-cli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wapm-cli b/wapm-cli index c2da5cda3b8..3e9b1ea7b2d 160000 --- a/wapm-cli +++ b/wapm-cli @@ -1 +1 @@ -Subproject commit c2da5cda3b8f9cf7dcea144f8cabdf342f38a0bf +Subproject commit 3e9b1ea7b2d1ddae9de2e2ae6a2af03cdae0e385 From 274367b1527038236503724aaf7f9408a39bf70c Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:15:20 -0800 Subject: [PATCH 2/6] Fixed CLI arguments issue --- Cargo.lock | 1 + Cargo.toml | 1 + src/bin/wasmer.rs | 17 ++++++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 24fa874a31a..a20878c06a8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1336,6 +1336,7 @@ name = "wasmer" version = "0.10.2" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 8724d91d4a3..5c48c6551d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ include = [ [dependencies] byteorder = "1.3" +clap="2.33.0" errno = "0.2" structopt = "0.3" wabt = "0.9.1" diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 26afcc03947..93add0a13ec 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -16,6 +16,7 @@ use std::io::Read; use std::path::PathBuf; use std::process::exit; use std::str::FromStr; +use clap; use std::collections::HashMap; use structopt::StructOpt; @@ -848,8 +849,22 @@ fn get_compiler_by_backend(backend: Backend) -> Option> { } fn main() { + // 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(|_| CLIOptions::Run(Run::from_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"))] From f0fc15a4aa1bff9025c295282cc9be6115037c33 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:15:31 -0800 Subject: [PATCH 3/6] Updated WAPM CLI to to 0.4.1 --- wapm-cli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wapm-cli b/wapm-cli index 3e9b1ea7b2d..3562d6dda52 160000 --- a/wapm-cli +++ b/wapm-cli @@ -1 +1 @@ -Subproject commit 3e9b1ea7b2d1ddae9de2e2ae6a2af03cdae0e385 +Subproject commit 3562d6dda52df526e6e1917dd33bb2454917ab9c From 8f625498197e439a01ee1745b555493242dcd720 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:18:52 -0800 Subject: [PATCH 4/6] Added changes in CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) 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. From a71b9519c453527145c2473e7f751e235b646142 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:19:42 -0800 Subject: [PATCH 5/6] Fix lint issues --- src/bin/wasmer.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 93add0a13ec..966c6c0f67a 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -9,6 +9,7 @@ )] extern crate structopt; +use clap; use std::env; use std::fs::{read_to_string, File}; use std::io; @@ -16,7 +17,6 @@ use std::io::Read; use std::path::PathBuf; use std::process::exit; use std::str::FromStr; -use clap; use std::collections::HashMap; use structopt::StructOpt; @@ -853,18 +853,15 @@ fn main() { // 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()) - } - }); + 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"))] From dc01afb3b5658d021929b349b6b79b10538f7494 Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 17:28:43 -0800 Subject: [PATCH 6/6] Use structopt clap instead of global clap --- Cargo.lock | 1 - Cargo.toml | 1 - src/bin/wasmer.rs | 3 +-- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a20878c06a8..24fa874a31a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1336,7 +1336,6 @@ name = "wasmer" version = "0.10.2" dependencies = [ "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 5c48c6551d1..8724d91d4a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ include = [ [dependencies] byteorder = "1.3" -clap="2.33.0" errno = "0.2" structopt = "0.3" wabt = "0.9.1" diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 966c6c0f67a..36e0100d671 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -9,7 +9,6 @@ )] extern crate structopt; -use clap; use std::env; use std::fs::{read_to_string, File}; use std::io; @@ -19,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;