wasmfmt 0.2.0

A WebAssembly formatter
Documentation

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:

cargo install wasmfmt

To install from source:

cargo install --path .

Build

To build the binary, use Cargo:

cargo build --release

The generated binary is located in target/release/wasmfmt.

Test

To run the tests, use Cargo:

cargo test

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:

wasmfmt examples/fac.wat --mode fix # `--mode fix` is optional

The alternative is --mode check, where a diff of the source code and the formatted code is printed to stdout:

wasmfmt examples/fact.wat --mode check

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.