Skip to content

Commit

Permalink
Merge #2383
Browse files Browse the repository at this point in the history
2383: Revert update to clap-beta back to structopt r=MarkMcCaskey a=MarkMcCaskey

Clap-beta hasn't had a release in a while and likely won't for a while longer. We're affected by bugs that have been fixed and not released. We shouldn't be depending on a beta library anyways when there's a stable equivalent. It's very understandable that the clap developers don't want to be burdened with publishing bug fixes when making major changes something in-progress -- they'd probably just end up with way more bug reports overall for things they never intended to support.

Revert #2162 

# Review

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


Co-authored-by: Mark McCaskey <[email protected]>
  • Loading branch information
bors[bot] and Mark McCaskey authored Jun 3, 2021
2 parents fbc56f7 + 0101280 commit 803e919
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 162 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C

## **[Unreleased]**

### Added

### Changed

### Fixed
- [#2383](https://github.com/wasmerio/wasmer/pull/2383) Fix bugs in the Wasmer CLI tool with the way `--version` and the name of the CLI tool itself were printed.

## 2.0.0-rc1 - 2020/06/02

### Added
Expand Down
81 changes: 29 additions & 52 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ wasmer-types = { version = "2.0.0-rc1", path = "../types" }
atty = "0.2"
colored = "2.0"
anyhow = "1.0"
clap = { version = "3.0.0-beta.2", features = ["suggestions", "derive", "cargo", "std", "color"], default-features = false }
structopt = { version = "0.3", features = ["suggestions"] }
# For the function names autosuggestion
distance = "0.4"
# For the inspect subcommand
Expand Down
34 changes: 17 additions & 17 deletions lib/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ use crate::commands::{Cache, Config, Inspect, Run, SelfUpdate, Validate};
use crate::error::PrettyError;
use anyhow::Result;

use clap::{Clap, ErrorKind};
use structopt::{clap::ErrorKind, StructOpt};

#[derive(Clap)]
#[derive(StructOpt)]
#[cfg_attr(
not(feature = "headless"),
clap(name = "wasmer", about = "WebAssembly standalone runtime.", author)
structopt(name = "wasmer", about = "WebAssembly standalone runtime.", author)
)]
#[cfg_attr(
feature = "headless",
clap(
structopt(
name = "wasmer-headless",
about = "Headless WebAssembly standalone runtime.",
author
Expand All @@ -28,43 +28,43 @@ use clap::{Clap, ErrorKind};
/// The options for the wasmer Command Line Interface
enum WasmerCLIOptions {
/// Run a WebAssembly file. Formats accepted: wasm, wat
#[clap(name = "run")]
#[structopt(name = "run")]
Run(Run),

/// Wasmer cache
#[clap(name = "cache")]
#[structopt(name = "cache")]
Cache(Cache),

/// Validate a WebAssembly binary
#[clap(name = "validate")]
#[structopt(name = "validate")]
Validate(Validate),

/// Compile a WebAssembly binary
#[cfg(feature = "compiler")]
#[clap(name = "compile")]
#[structopt(name = "compile")]
Compile(Compile),

/// Compile a WebAssembly binary into a native executable
#[cfg(all(feature = "staticlib", feature = "compiler"))]
#[clap(name = "create-exe")]
#[structopt(name = "create-exe")]
CreateExe(CreateExe),

/// Get various configuration information needed
/// to compile programs which use Wasmer
#[clap(name = "config")]
#[structopt(name = "config")]
Config(Config),

/// Update wasmer to the latest version
#[clap(name = "self-update")]
#[structopt(name = "self-update")]
SelfUpdate(SelfUpdate),

/// Inspect a WebAssembly file
#[clap(name = "inspect")]
#[structopt(name = "inspect")]
Inspect(Inspect),

/// Run spec testsuite
#[cfg(feature = "wast")]
#[clap(name = "wast")]
#[structopt(name = "wast")]
Wast(Wast),
}

Expand Down Expand Up @@ -101,15 +101,15 @@ pub fn wasmer_main() {
let command = args.get(1);
let options = match command.unwrap_or(&"".to_string()).as_ref() {
"cache" | "compile" | "config" | "create-exe" | "help" | "inspect" | "run"
| "self-update" | "validate" | "wast" => WasmerCLIOptions::parse(),
| "self-update" | "validate" | "wast" => WasmerCLIOptions::from_args(),
_ => {
WasmerCLIOptions::try_parse_from(args.iter()).unwrap_or_else(|e| {
WasmerCLIOptions::from_iter_safe(args.iter()).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`
ErrorKind::DisplayVersion | ErrorKind::DisplayHelp => e.exit(),
_ => WasmerCLIOptions::Run(Run::parse()),
ErrorKind::VersionDisplayed | ErrorKind::HelpDisplayed => e.exit(),
_ => WasmerCLIOptions::Run(Run::from_args()),
}
})
}
Expand Down
8 changes: 4 additions & 4 deletions lib/cli/src/commands/cache.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
use crate::common::get_cache_dir;
use anyhow::{Context, Result};
use clap::Clap;
use std::fs;
use structopt::StructOpt;

#[derive(Debug, Clap)]
#[derive(Debug, StructOpt)]
/// The options for the `wasmer cache` subcommand
pub enum Cache {
/// Clear the cache
#[clap(name = "clean")]
#[structopt(name = "clean")]
Clean,

/// Display the location of the cache
#[clap(name = "dir")]
#[structopt(name = "dir")]
Dir,
}

Expand Down
16 changes: 8 additions & 8 deletions lib/cli/src/commands/compile.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
use crate::store::{EngineType, StoreOptions};
use crate::warning;
use anyhow::{Context, Result};
use clap::Clap;
use std::path::PathBuf;
use structopt::StructOpt;
use wasmer::*;

#[derive(Debug, Clap)]
#[derive(Debug, StructOpt)]
/// The options for the `wasmer compile` subcommand
pub struct Compile {
/// Input file
#[clap(name = "FILE", parse(from_os_str))]
#[structopt(name = "FILE", parse(from_os_str))]
path: PathBuf,

/// Output file
#[clap(name = "OUTPUT PATH", short = 'o', parse(from_os_str))]
#[structopt(name = "OUTPUT PATH", short = "o", parse(from_os_str))]
output: PathBuf,

/// Output path for generated header file
#[clap(name = "HEADER PATH", long = "header", parse(from_os_str))]
#[structopt(name = "HEADER PATH", long = "header", parse(from_os_str))]
header_path: Option<PathBuf>,

/// Compilation Target triple
#[clap(long = "target")]
#[structopt(long = "target")]
target_triple: Option<Triple>,

#[clap(flatten)]
#[structopt(flatten)]
store: StoreOptions,

#[clap(short = 'm', multiple = true)]
#[structopt(short = "m", multiple = true)]
cpu_features: Vec<CpuFeature>,
}

Expand Down
18 changes: 9 additions & 9 deletions lib/cli/src/commands/config.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
use crate::VERSION;
use anyhow::{Context, Result};
use clap::Clap;
use std::env;
use std::path::PathBuf;
use structopt::StructOpt;

#[derive(Debug, Clap)]
#[derive(Debug, StructOpt)]
/// The options for the `wasmer config` subcommand
pub struct Config {
/// Print the installation prefix.
#[clap(long, conflicts_with = "pkg-config")]
#[structopt(long, conflicts_with = "pkg-config")]
prefix: bool,

/// Directory containing Wasmer executables.
#[clap(long, conflicts_with = "pkg-config")]
#[structopt(long, conflicts_with = "pkg-config")]
bindir: bool,

/// Directory containing Wasmer headers.
#[clap(long, conflicts_with = "pkg-config")]
#[structopt(long, conflicts_with = "pkg-config")]
includedir: bool,

/// Directory containing Wasmer libraries.
#[clap(long, conflicts_with = "pkg-config")]
#[structopt(long, conflicts_with = "pkg-config")]
libdir: bool,

/// Libraries needed to link against Wasmer components.
#[clap(long, conflicts_with = "pkg-config")]
#[structopt(long, conflicts_with = "pkg-config")]
libs: bool,

/// C compiler flags for files that include Wasmer headers.
#[clap(long, conflicts_with = "pkg-config")]
#[structopt(long, conflicts_with = "pkg-config")]
cflags: bool,

/// It outputs the necessary details for compiling
/// and linking a program to Wasmer, using the `pkg-config` format.
#[clap(long)]
#[structopt(long)]
pkg_config: bool,
}

Expand Down
Loading

0 comments on commit 803e919

Please sign in to comment.