Skip to content

Commit

Permalink
Merge #992
Browse files Browse the repository at this point in the history
992: Update wapm-cli to latest version r=syrusakbary a=syrusakbary

<!-- 
Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test:
https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests

-->

# Description

This PR:
* [x] Updates WAPM version to 0.4.1
* [x] Fixes arguments issue introduced in #990

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Syrus <[email protected]>
  • Loading branch information
bors[bot] and syrusakbary authored Nov 21, 2019
2 parents 518cd00 + dc01afb commit 9e144c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
17 changes: 14 additions & 3 deletions src/bin/wasmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -848,8 +848,19 @@ fn get_compiler_by_backend(backend: Backend) -> Option<Box<dyn Compiler>> {
}

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 <SUBCOMMAND>`
// 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"))]
Expand Down
2 changes: 1 addition & 1 deletion wapm-cli

0 comments on commit 9e144c6

Please sign in to comment.