Crates.io | cargo-cmd |
lib.rs | cargo-cmd |
version | 0.3.1 |
source | src |
created_at | 2018-09-10 00:23:07.487018 |
updated_at | 2020-03-19 15:56:17.48411 |
description | Alias any shell command in your Cargo.toml. It's like npm scripts, but for cargo. |
homepage | |
repository | https://github.com/danreeves/cargo-cmd |
max_upload_size | |
id | 83902 |
size | 40,301 |
Alias any shell command in your Cargo.toml
. It's like npm
scripts, but for cargo
.
cargo install cargo-cmd
You can define your commands in Cargo.toml
under the [package.metadata.commands]
table, like so:
[package.metadata.commands]
greet = "echo 'Hello, planet!'"
Now you can run cargo cmd greet
:
$ cargo cmd greet
> echo 'Hello, planet!'
Hello, planet!
It's possible to pass arguments into your command by passing them directly to cargo cmd
.
[package.metadata.commands]
echo = "echo"
$ cargo cmd echo 'Hello, planet!'
> echo 'Hello, planet!'
Hello, planet!
You are able to set up commands to run before and after your command by prefixing the name with pre
or post
respectively.
[package.metadata.commands]
pretest = "./setup.sh"
test = "cargo test"
posttest = "./teardown.sh"
$ cargo cmd test
[pretest]
> ./setup.sh
Setting up DB...
[test]
> cargo test
...
[posttest]
> ./teardown.sh
Tearing down DB...