Ultra-Lightweight Zero-Dependency Rust Cargo Task Runner.
shell
cargo install -f cargo-task
cargo help task
cargo-task
automation tasks.shell
cargo task ct-init
cd .cargo-task
cargo new --bin my-task
cd ..
cargo task my-task
cargo task ct-init
- creates the .cargo-task
directory and .gitignore
.cargo task my-task
- runs the crate named my-task
defined in the .cargo-task
directory.It's that simple!
cargo-task
uses a metadata format called AtAt - because it uses @
signs:
rust
/*
@ct-default@ true @@
@ct-task-deps@
one
two
@@
*/
Some things to know about AtAt:
- protocol: @key@ value @@
.
- the first @
for the key must be the first character on a line.
- the value is terminated by a two ats, "@@
".
- the value can contain newlines or be on a single line.
- you probably want it in a rust comment block : )
These directives will be read from your main.rs
file when parsing the
.cargo-task
crates.
rust
/*
@ct-default@ true @@
*/
Default tasks will be executed if the task list is empty on cargo task
invocations.
rust
/*
@ct-bootstrap@ true @@
*/
Bootstrap tasks will always be executed before any task-list tasks. Also, the cargo-task metadata will be reloaded after bootstrap tasks are executed. You can use this to download / install / configure additional tasks.
rust
/*
@ct-task-deps@
my-first-dependency
my-second-dependency
@@
*/
A whitespace delimited list of tasks that must be run prior to the current task. Can be on a single line or multiple lines.
cargo_task_util
module.This module will be available at the root of your crate during build time.
To include it, simply add a mod
directive in your main.rs
file.
```rust /* @ct-default@ true @@ */
mod cargotaskutil; use cargotaskutil::*;
fn main() { // cargo task metadata env helper let env = ct_env();
// print out some cool cargo-task metadata
// (this does the same thing as `cargo task ct-meta`)
println!("{:#?}", env);
// also includes cargo-task special log helpers
ct_warn!("ahh, a warning! {:?}", std::time::SystemTime::now());
} ```
cargo_task_util::CTEnv
also includes a utility for exporting environment
variables.
If you just use the rust std::env::set_var
function, the variable will
be set for the current task execution, but no other tasks will see it.
Instead you can use cargo_task_util::CTEnv::set_env
function.
You probably want to do this in a "bootstrap" task so it is available to other tasks that are run later.
```rust /* @ct-bootstrap@ true @@ */
mod cargotaskutil; use cargotaskutil::*;
fn main() { // cargo task metadata env helper let env = ct_env();
// set a variable that will be available in other tasks.
env.set_env("MY_VARIABLE", "MY_VALUE");
} ```