Cargo Commander serves to fill the gap in the cargo
commands capabilities, namely not being able to run commands in a
similar fashion that npm
does with scripts.
Either create your commands under a [commands]
section in your Cargo.toml
file, or create a new
Commands.toml
file which uses the exact same syntax as if it had been under the commands section.
```shell
cargo install cargo-commander
cargo cmd COMMAND ```
Read the full guide in our wiki.
A command can either be a string or a command object using the below fields to customize its behavior.
text
cmd = String or Array, where an array can either contain string commands or other command objects
parallel = true/false, only makes a difference if the command object contains an array, makes all commands run in parallel
shell = String, the syntax is simply "program arg arg arg"
env = Array, an array of strings in the format "VAR=SOMETHING"
args = Array, an array of strings in the format "ARG=Default value", if no default is given an empty string is used
working_dir = String, path to the directory to use as working directory, either absolute or relative
Here are some examples of how you can set up commands.
```toml
[commands] hello = "echo world" multiple = ["echo first", "echo second"] advanced = { cmd = "print('Hello from python!')", shell = "python -c" } [commands.test] hello = "echo test" witharguments = { cmd = "echo $ARG1 $ARG2", args = ["ARG1", "ARG2=Default value"] } withenv = { cmd = ["echo $MYENV"], env = ["MYENV=Hello"] } withboth = { cmd = ["echo $MYENV $ARG"], env = ["MY_ENV=Hello"], args = ["ARG=Default"] } ```
```toml
hello = "echo world" super_advanced = { cmd = [ "echo we", "echo run", "echo in", "echo parallel" ], parallel = true } [git] status = "git status" ```
If you want to see more examples, check out the Commands.toml
file in the repository.