Awesome
Cargo Watch
Cargo Watch is a tool to watch your Cargo-based project and run commands when files change. It focuses on the Rust development experience and aims to be flexible enough to suit most without becoming complicated to use.
If you've used nodemon, guard, or entr, it will probably feel familiar.
Looking for a similar tool that you can use for other kinds of projects? Try Watchexec, this project's bigger sibling.
Install
<a href="https://repology.org/project/cargo-watch/versions"><img align="right" src="https://repology.org/badge/vertical-allrepos/cargo-watch.svg" alt="Packaging status"></a>
Install or upgrade today with Binstall:
$ cargo binstall cargo-watch
Or with cargo (rustc >= 1.60.0) if you don't have Binstall yet:
$ cargo install cargo-watch
Or unpack directly from the latest pre-built release.
This repository contains a manual page and shell completions that you may want to install; the pre-built packages also include these.
Use
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:
Augment
Cargo Watch pairs well with:
Extend
- watchexec library: the engine behind this tool.
- clearscreen: to clear the (terminal) screen on every platform.
- command group: to run commands in process groups.
- ignore files: to find, parse, and interpret ignore files.
- project origins: to find the origin(s) directory of a project.
- notify: to respond to file modifications (third-party).
- globset: to match globs (third-party).