Stage 2.6: Cargo Subcommands
cargo subcommands are an option to add additional commands which are developed by the community to customize your developing experience.
To install a cargo subcommand, you simply run:
cargo install name-of-subcommand
For example to install the
cargo-watch
subcommand, you simply run: cargo install cargo-watch
.
To see all available option for this new cargo subcommand, just run:
cargo watch --help
cargo watch is a pretty useful command to run or test your code everytime something has
changed. It can be used like: cargo watch -x run
. This would execute
cargo run
whenever it detects a change.
There are other useful commands like cargo-edit which adds multiple subcommands (cargo add, cargo rm and cargo upgrade) to handle dependencies via CLI commands.
Further cargo subcommands can be found here: https://github.com/topics/cargo-subcommand