Update to clap 3.* (#4082)

* Update to clap 3.0

This commit migrates all CLI commands internally used in this project
from structopt/clap2 to clap 3. The intent here is to ensure that we're
using maintained versions of the dependencies as structopt and clap 2
are less maintained nowadays. Most transitions were pretty
straightforward and mostly dealing with structopt/clap3 differences.

* Fix a number of `cargo deny` errors

This commit fixes a few errors around duplicate dependencies which
arose from the prior update to clap3. This also uses a new feature in
`deny.toml`, `skip-tree`, which allows having a bit more targeted
ignores for skips of duplicate version checks. This showed a few more
locations in Wasmtime itself where we could update some dependencies.
This commit is contained in:
Alex Crichton
2022-04-28 12:47:12 -05:00
committed by GitHub
parent 871a9d93f2
commit 5fe06f7345
30 changed files with 295 additions and 325 deletions

View File

@@ -4,20 +4,15 @@
//! See `wasmtime --help` for usage.
use anyhow::Result;
use structopt::{clap::AppSettings, clap::ErrorKind, StructOpt};
use clap::{ErrorKind, Parser};
use wasmtime_cli::commands::{
CompileCommand, ConfigCommand, RunCommand, SettingsCommand, WastCommand,
};
/// Wasmtime WebAssembly Runtime
#[derive(StructOpt)]
#[structopt(
name = "wasmtime",
version = env!("CARGO_PKG_VERSION"),
global_settings = &[
AppSettings::VersionlessSubcommands,
AppSettings::ColoredHelp
],
#[derive(Parser)]
#[clap(
version,
after_help = "If a subcommand is not provided, the `run` subcommand will be used.\n\
\n\
Usage examples:\n\
@@ -34,7 +29,7 @@ use wasmtime_cli::commands::{
\n \
wasmtime example.wasm --invoke add 1 2\n"
)]
enum WasmtimeApp {
enum Wasmtime {
// !!! IMPORTANT: if subcommands are added or removed, update `parse_module` in `src/commands/run.rs`. !!!
/// Controls Wasmtime configuration settings
Config(ConfigCommand),
@@ -48,7 +43,7 @@ enum WasmtimeApp {
Wast(WastCommand),
}
impl WasmtimeApp {
impl Wasmtime {
/// Executes the command.
pub fn execute(self) -> Result<()> {
match self {
@@ -62,14 +57,13 @@ impl WasmtimeApp {
}
fn main() -> Result<()> {
WasmtimeApp::from_iter_safe(std::env::args())
.unwrap_or_else(|e| match e.kind {
ErrorKind::HelpDisplayed
| ErrorKind::VersionDisplayed
| ErrorKind::MissingArgumentOrSubcommand => e.exit(),
_ => WasmtimeApp::Run(
RunCommand::from_iter_safe(std::env::args()).unwrap_or_else(|_| e.exit()),
),
Wasmtime::try_parse()
.unwrap_or_else(|e| match e.kind() {
ErrorKind::DisplayHelp
| ErrorKind::DisplayVersion
| ErrorKind::MissingSubcommand
| ErrorKind::MissingRequiredArgument => e.exit(),
_ => Wasmtime::Run(RunCommand::parse()),
})
.execute()
}