#cargo-command #cargo-toml #command #cargo #script #npm #cmd

app cargo-cmd

Alias any shell command in your Cargo.toml. It's like npm scripts, but for cargo.

5 unstable releases

Uses old Rust 2015

0.3.1 Mar 19, 2020
0.3.0 Nov 16, 2018
0.2.1 Oct 12, 2018
0.2.0 Oct 5, 2018
0.1.0 Sep 10, 2018

#407 in Cargo plugins

Download history 15/week @ 2023-12-14 69/week @ 2023-12-28 4/week @ 2024-01-04 25/week @ 2024-01-25 7/week @ 2024-02-01 10/week @ 2024-02-08 15/week @ 2024-02-15 18/week @ 2024-02-22 14/week @ 2024-02-29 56/week @ 2024-03-07 64/week @ 2024-03-14 23/week @ 2024-03-21

159 downloads per month

MIT license

12KB
205 lines

cargo-cmd

crates.io version build status docs.rs docs license

Alias any shell command in your Cargo.toml. It's like npm scripts, but for cargo.

Installation

cargo install cargo-cmd

Usage

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!

Advanced use

Passing arguments

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!

Pre and Post commands

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...

License

MIT © Dan Reeves

Dependencies

~1.7–2.7MB
~48K SLoC