$ cargo watch
Cargo Watch watches over your project's source for changes, and runs Cargo commands when they occur.
If you've used nodemon, guard, or entr, it will probably feel familiar.
- License: Apache 2.0.
- Website: watchexec.github.io.
- Minimum Supported Rust Version: 1.58.0.
Install
Pre-built binaries are available from the website or alternatively on the Github Releases tab.
With cargo-binstall:
$ cargo binstall cargo-watch
With cargo:
$ cargo install cargo-watch
From source:
# clone:
$ git clone https://github.com/watchexec/cargo-watch
$ cd cargo-watch
# build:
$ cargo build --release
$ target/release/cargo-watch -h
# or install:
$ cargo install --path .
$ cargo watch -h
This repository contains a manual page and shell completions that you may want to install; the pre-built packages also include these.
Usage
By default, it runs check
. You can easily override this, though:
$ cargo watch [-x command]...
A few examples:
# Run tests only
$ cargo watch -x test
# Run check then tests
$ cargo watch -x check -x test
# Run run with arguments
$ cargo watch -x 'run -- --some-arg'
# Run an arbitrary command
$ cargo watch -- echo Hello world
# Run with features passed to cargo
$ cargo watch --features "foo,bar"
There's a lot more you can do! Check out:
About
Created by Félix Saparelli and awesome contributors.