tsk: a simple task runner with TOML syntax
example
$ cat tasks.toml
[tasks.hello_world]
cmds = ["echo Hello World!"]
$ tsk hello_world
Hello World!
see examples/tasks.toml
for complete usage and configuration reference.
installation
via Homebrew:
brew tap notnmeyer/tsk
brew install tsk
alternatively, you can install directly from releases page or see the install_release script.
from source
- without tsk installed
go build -o ./bin/tsk -v cmd/tsk/tsk.go
- with tsk installed
tsk build
features
tasks.toml locations
tsk will look for a tasks.toml
file in the current directory, looking in parent directories if one isn't found.
you can specify a file in another location or with another name with the --file
flag.
dependencies and dependency groups
tasks can depend on other tasks as dependencies via a task's deps
key. dependencies are organized in groups represented in toml as nested arrays. dependency groups are executed in the order they are defined in the deps
key, while tasks within a group are executed in parallel.
[tasks.one]
cmds = ["echo one"]
[tasks.two]
cmds = ["echo two"]
[tasks.three]
cmds = ["echo three"]
[tasks.main]
deps = [
["one", "two"], # one and two will run in parallel
["three"], # three will run after one and two have finished
]
cmds = ["echo main"]
let shell be shell
writing shell in toml or yaml files sucks—you miss out of syntax highlighting, linting, and other tools like shellcheck.
you may omit a task's cmds
field, which instead runs a script with the same name as the task from the tsk
directory relative to the location of your tasks.toml
file.
if you need to write anything more complicated than one or two short commands in a task, use a script!
try tsk --file examples/tasks.toml no_cmd
to see this in action.
environment variables
tsk loads environment variables and merges them with the precendence listed below. items earlier in the list are overriden by items lower in the list.
- the top-level
env
key
- the top-level
dotenv
key
tasks.<task_name>.env
- the parent process, e.g.,
MY_VAR=hey tsk ...
tasks.<task_name>.dotenv
"pure" tasks
setting pure = true
on a task will prevent the parent process's environment from being inherited. Similarly, the CLI argument --pure
will prevent any task from inheriting the parent's env. the only exceptions are $USER
and $HOME
, which are always inherited.
toml 1.1.0
some upcoming toml 1.1.0 features are supported. of note, newlines and trailing commas are now allowed in inline tables:
[tasks.example]
env = {
msg1 = "hello",
msg2 = "world",
}
cmds = ["echo $msg1 $msg2"]