Files
wasmtime/src/bin/wasmtime.rs
Alex Crichton 8ebaaf928d Remove the wasmtime wasm2obj command (#3301)
* Remove the `wasmtime wasm2obj` command

This commit removes the `wasm2obj` subcommand of the `wasmtime` CLI.
This subcommand has a very long history and dates back quite far. While
it's existed, however, it's never been documented in terms of the output
it's produced. AFAIK it's only ever been used for debugging to see the
machine code output of Wasmtime on some modules. With recent changes to
the module serialization output the output of `wasmtime compile`, the
`*.cwasm` file, is now a native ELF file which can be fed to standard
tools like `objdump`. Consequently I dont think there's any remaining
need to keep `wasm2obj` around itself, so this commit removes the
subcommand.

* More code to delete

* Try to fix debuginfo tests
2021-09-08 10:40:58 -05:00

76 lines
2.5 KiB
Rust

//! The `wasmtime` command line tool.
//!
//! Primarily used to run WebAssembly modules.
//! See `wasmtime --help` for usage.
use anyhow::Result;
use structopt::{clap::AppSettings, clap::ErrorKind, StructOpt};
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
],
after_help = "If a subcommand is not provided, the `run` subcommand will be used.\n\
\n\
Usage examples:\n\
\n\
Running a WebAssembly module with a start function:\n\
\n \
wasmtime example.wasm
\n\
Passing command line arguments to a WebAssembly module:\n\
\n \
wasmtime example.wasm arg1 arg2 arg3\n\
\n\
Invoking a specific function (e.g. `add`) in a WebAssembly module:\n\
\n \
wasmtime example.wasm --invoke add 1 2\n"
)]
enum WasmtimeApp {
// !!! IMPORTANT: if subcommands are added or removed, update `parse_module` in `src/commands/run.rs`. !!!
/// Controls Wasmtime configuration settings
Config(ConfigCommand),
/// Compiles a WebAssembly module.
Compile(CompileCommand),
/// Runs a WebAssembly module
Run(RunCommand),
/// Displays available Cranelift settings for a target.
Settings(SettingsCommand),
/// Runs a WebAssembly test script file
Wast(WastCommand),
}
impl WasmtimeApp {
/// Executes the command.
pub fn execute(self) -> Result<()> {
match self {
Self::Config(c) => c.execute(),
Self::Compile(c) => c.execute(),
Self::Run(c) => c.execute(),
Self::Settings(c) => c.execute(),
Self::Wast(c) => c.execute(),
}
}
}
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()),
),
})
.execute()
}