cargo-prepost
cargo-prepost is a wrapper tool that allows you to automatically run custom scripts or binaries before and after any cargo command. This makes it easy to automate and customize your Rust development workflow by hooking into build, test, or run steps.
Installation
Setup
Add the following line to your shell configuration file (e.g., .bashrc or .zshrc):
This ensures that all cargo commands are automatically proxied through cargo-prepost.
Usage
Simply use cargo as usual. If there are corresponding pre/post scripts, they will be executed automatically.
For example:
When you run the above command, the following steps occur:
prepost/prerun(orprepost/prerun.rs) is executed- The original
cargo runcommand is executed prepost/postrun(orprepost/postrun.rs) is executed
If a Rust file such as prepost/prerun.rs exists, it will be automatically compiled before execution.
Examples
See the examples directory for sample projects and pre/post scripts. You can customize these scripts to fit your own project's needs.