Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Defining tasks

A task is a [tasks.<name>] table. It runs shell commands, a Rhai script, or a WASM plugin — exactly one of run / script / wasm.

[tasks.fmt]
desc = "Format and lint"
run = ["cargo fmt", "cargo clippy --fix --allow-dirty"]

Dependencies

[tasks.check]
desc = "Full check pipeline"
depends = ["fmt", "lint", "test"]   # run these first

Dependencies form a DAG; yatr runs each task as soon as its dependencies finish (a ready-queue scheduler), bounded by --parallel.

Parallel commands

[tasks.lint]
parallel = true
run = ["cargo fmt --check", "cargo clippy -- -D warnings", "cargo doc --no-deps"]

Environment, working dir, shell

[env]                       # global
RUST_LOG = "debug"

[tasks.migrate]
cwd = "./backend"
env = { DATABASE_URL = "postgres://localhost/dev" }
shell = true
run = ["diesel migration run"]

Long-running processes

[tasks.dev]
foreground = true           # inherit stdio; not cached
run = ["cargo watch -x run"]

Full task reference

FieldMeaning
descHuman description
run / script / wasmWhat to execute (mutually exclusive)
dependsTasks to run first
parallelRun run commands concurrently
env, cwd, shellEnvironment, working dir, shell mode
foregroundInherit stdio (dev servers); not cached
sources, outputsCaching inputs/outputs
watchFile patterns for yatr watch
no_cache, allow_failure, timeoutPer-task behaviour