xref: /wasmtime-44.0.1/docs/cli-options.md (revision 331b0dee)
1# CLI Options for `wasmtime`
2
3The `wasmtime` CLI is organized into a few subcommands. If no subcommand is
4provided it'll assume `run`, which is to execute a wasm file. The subcommands
5supported by `wasmtime` are:
6
7## `help`
8
9This is a general subcommand used to print help information to the terminal. You
10can execute any number of the following:
11
12```sh
13$ wasmtime help
14$ wasmtime --help
15$ wasmtime -h
16$ wasmtime help run
17$ wasmtime run -h
18```
19
20When in doubt, try running the `help` command to learn more about functionality!
21
22## `run`
23
24This is the `wasmtime` CLI's main subcommand, and it's also the default if no
25other subcommand is provided. The `run` command will execute a WebAssembly
26module. This means that the module will be compiled to native code,
27instantiated, and then optionally have an export executed.
28
29The `wasmtime` CLI will automatically hook up any WASI-related imported
30functionality, but at this time if your module imports anything else it will
31fail instantiation.
32
33The `run` command takes one positional argument which is the name of the module
34to run:
35
36```sh
37$ wasmtime run foo.wasm
38$ wasmtime foo.wasm
39```
40
41Note that the `wasmtime` CLI can take both a binary WebAssembly file (`*.wasm`)
42as well as the text format for WebAssembly (`*.wat`):
43
44```sh
45$ wasmtime foo.wat
46```
47
48## `wast`
49
50The `wast` command executes a `*.wast` file which is the test format for the
51official WebAssembly spec test suite. This subcommand will execute the script
52file which has a number of directives supported to instantiate modules, link
53tests, etc.
54
55Executing this looks like:
56
57```sh
58$ wasmtime wast foo.wast
59```
60
61## `config`
62
63This subcommand is used to control and edit local Wasmtime configuration
64settings. The primary purpose of this currently is to configure [how Wasmtime's
65code caching works](./cli-cache.md). You can create a new configuration file for
66you to edit with:
67
68```sh
69$ wasmtime config new
70```
71
72And that'll print out the path to the file you can edit.
73
74## `wasm2obj`
75
76This is an experimental subcommand to compile a WebAssembly module to native
77code. Work for this is still heavily under development, but you can execute this
78with:
79
80```sh
81$ wasmtime wasm2obj foo.wasm foo.o
82```
83
84## `compile`
85
86This subcommand is used to Ahead-Of-Time (AOT) compile a WebAssembly module to produce
87a "compiled wasm" (.cwasm) file.
88
89The `wasmtime run` subcommand can then be used to run a AOT-compiled WebAssembly module:
90
91```sh
92$ wasmtime compile foo.wasm
93$ wasmtime foo.cwasm
94```
95
96AOT-compiled modules can be run from hosts that are compatible with the target
97environment of the AOT-completed module.
98
99## `settings`
100
101This subcommand is used to print the available Cranelift settings for a given target.
102
103When run without options, it will print the settings for the host target and also
104display what Cranelift settings are inferred for the host:
105
106```sh
107$ wasmtime settings
108```
109