From 1685455eb64bf1f770cbebe861e3f39d72800bef Mon Sep 17 00:00:00 2001 From: Syrus Date: Wed, 20 Nov 2019 14:50:37 -0800 Subject: [PATCH 1/3] Allow to do wasmer execution without the `run` argument --- src/bin/wasmer.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 7af5df3e258..012758504e1 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -842,7 +842,20 @@ fn get_compiler_by_backend(backend: Backend) -> Option> { } fn main() { - let options = CLIOptions::from_args(); + let options = { + let args: Vec = env::args().into_iter().filter(|x| !x.starts_with("-")).collect(); + match args.get(1).map_or("", |s| &s) { + // Default + "run" | "cache" | "validate" | "self_update" | "" => { + CLIOptions::from_args() + } + // Wasmer trying to run a file directly + _ => { + let run_options = Run::from_args(); + CLIOptions::Run(run_options) + } + } + }; match options { CLIOptions::Run(options) => run(options), #[cfg(not(target_os = "windows"))] From cb7fcb94522d8b9b43d9322800553d81578555d7 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 20 Nov 2019 14:59:55 -0800 Subject: [PATCH 2/3] Simplify default run logic --- src/bin/wasmer.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 012758504e1..ef3ea2d9eac 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -842,20 +842,8 @@ fn get_compiler_by_backend(backend: Backend) -> Option> { } fn main() { - let options = { - let args: Vec = env::args().into_iter().filter(|x| !x.starts_with("-")).collect(); - match args.get(1).map_or("", |s| &s) { - // Default - "run" | "cache" | "validate" | "self_update" | "" => { - CLIOptions::from_args() - } - // Wasmer trying to run a file directly - _ => { - let run_options = Run::from_args(); - CLIOptions::Run(run_options) - } - } - }; + let options = StructOpt::from_iter_safe(env::args()) + .unwrap_or_else(|_| CLIOptions::Run(Run::from_args())); match options { CLIOptions::Run(options) => run(options), #[cfg(not(target_os = "windows"))] From 76e346b7080e3ef2a8e71cffaebf82a1916ce429 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 20 Nov 2019 15:50:46 -0800 Subject: [PATCH 3/3] Clean up from feedback, update changelog --- CHANGELOG.md | 1 + src/bin/wasmer.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40a600caf82..c658e024d3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#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. ## 0.10.2 - 2019-11-18 diff --git a/src/bin/wasmer.rs b/src/bin/wasmer.rs index 5df7d5e5d40..26afcc03947 100644 --- a/src/bin/wasmer.rs +++ b/src/bin/wasmer.rs @@ -848,7 +848,7 @@ fn get_compiler_by_backend(backend: Backend) -> Option> { } fn main() { - let options = StructOpt::from_iter_safe(env::args()) + let options = CLIOptions::from_iter_safe(env::args()) .unwrap_or_else(|_| CLIOptions::Run(Run::from_args())); match options { CLIOptions::Run(options) => run(options),