Use structopt instead of docopt.

This commit refactors the Wasmtime CLI tools to use `structopt` instead of
`docopt`.

The `wasmtime` tool now has the following subcommands:

* `config new` - creates a new Wasmtime configuration file.
* `run` - runs a WebAssembly module.
* `wasm2obj` - translates a Wasm module to native object file.
* `wast` - runs a test script file.

If no subcommand is specified, the `run` subcommand is used. Thus,
`wasmtime foo.wasm` should continue to function as expected.

The `wasm2obj` and `wast` tools still exist, but delegate to the same
implementation as the `wasmtime` subcommands.  The standalone `wasm2obj` and
`wast` tools may be removed in the future in favor of simply using `wasmtime`.

Included in this commit is a breaking change to the default Wasmtime
configuration file: it has been renamed from `wasmtime-cache-config.toml` to
simply `config.toml`.  The new name is less specific which will allow for
additional (non-cache-related) settings in the future.

There are some breaking changes to improve command line UX:

* The `--cache-config` option has been renamed to `--config`.
* The `--create-config-file` option has moved to the `config new` subcommand.
As a result, the `wasm2obj` and `wast` tools cannot be used to create a new
config file.
* The short form of the `--optimize` option has changed from
`-o` to `-O` for consistency.
* The `wasm2obj` command takes the output object file as a
required positional argument rather than the former required output *option*
(e.g. `wasmtime wasm2obj foo.wasm foo.obj`).
This commit is contained in:
Peter Huene
2019-12-17 15:38:00 -05:00
parent d142a39113
commit 59258730c2
14 changed files with 900 additions and 891 deletions

53
Cargo.lock generated
View File

@@ -316,7 +316,7 @@ dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim 0.8.0",
"strsim",
"textwrap",
"unicode-width",
"vec_map",
@@ -550,18 +550,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "docopt"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f525a586d310c87df72ebcd98009e57f1cc030c8c268305287a476beb653969"
dependencies = [
"lazy_static",
"regex",
"serde",
"strsim 0.9.2",
]
[[package]]
name = "dynasm"
version = "0.5.2"
@@ -1185,6 +1173,17 @@ dependencies = [
"log",
]
[[package]]
name = "proc-macro-error"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aeccfe4d5d8ea175d5f0e4a2ad0637e0f4121d63bd99d356fb1f39ab2e7c6097"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "proc-macro-hack"
version = "0.5.11"
@@ -1622,10 +1621,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "strsim"
version = "0.9.2"
name = "structopt"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "032c03039aae92b350aad2e3779c352e104d919cb192ba2fabbd7b831ce4f0f6"
checksum = "30b3a3e93f5ad553c38b3301c8a0a0cec829a36783f6a0c467fc4bf553a5f5bf"
dependencies = [
"clap",
"structopt-derive",
]
[[package]]
name = "structopt-derive"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea692d40005b3ceba90a9fe7a78fa8d4b82b0ce627eebbffc329aab850f3410e"
dependencies = [
"heck",
"proc-macro-error",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "syn"
@@ -1950,12 +1966,10 @@ name = "wasmtime"
version = "0.7.0"
dependencies = [
"anyhow",
"docopt",
"file-per-thread-logger",
"pretty_env_logger",
"rayon",
"region",
"serde",
"target-lexicon",
"thiserror",
"wasi-common",
@@ -1973,14 +1987,13 @@ name = "wasmtime-cli"
version = "0.7.0"
dependencies = [
"anyhow",
"docopt",
"faerie",
"file-per-thread-logger",
"libc",
"more-asserts",
"pretty_env_logger",
"rayon",
"serde",
"structopt",
"target-lexicon",
"test-programs",
"wasi-common",