wasmfmt
A tool for formatting your .wat
code according to style rules.
It can be used as either a command-line tool or a Rust library.
For more information on how to use the library, see the API docs.
Install
To install the tool, use Cargo.
To install from crates.io:
To install from source:
Build
To build the binary, use Cargo:
The generated binary is located in target/release/wasmfmt
.
Test
To run the tests, use Cargo:
Usage
The tool has two primary operating modes, specified by the --mode
flag.
The default is --mode fix
, where the input file is overwritten with the formatted code:
The alternative is --mode check
, where a diff of the source code and the formatted code is printed to stdout:
This is useful e. g. when running in a CI environment as part of an automated style check.
Options
Option | Description | Default |
---|---|---|
file |
The file to operate on. | Reads from stdin . |
--mode |
The operating mode; overwrite the file, or show a diff. | fix |
License
wasmfmt
is distributed under the terms of the MIT license. See LICENSE for details.