Usage¶
Open a terminal in folder with a task file. Type ./task help and you should get an output like this:
task <command> [options]
commands:
| Command | Option | Description |
|---------|--------|---------------------------------|
| help | [grep] | Show help for commands. |
| install | | Install build dependencies. |
| lint | | Run pre-commit. |
| version | | Show version of required tools. |
Every command supports an additional tfhelp keyword as first argument. ./task <command> tfhelp filters the help table by the command name.
Choose a task and run it with ./task <command> [option].
With the command switch case it is also possible to run multiple commands: ./task install,lint
Install¶
This project also provides a library with reusable commands.
You can clone and install the project as followed:
The install script sets up the global default Taskfile and adds the t alias.
To undo the installation run:
The uninstall script removes the shell integration block from your profile.
Global default¶
The install script adds a task() shell function to your profile. The function calls $HOME/taskfile.build/task.template directly, so nothing is copied to your PATH.
When you run task in a directory that contains a local ./task file, that file is called. Otherwise, the global default $HOME/taskfile.build/task.template is used. This makes the Taskfile library commands available in any directory.
The t alias is a shorthand for task:
Completion¶
With the output of task help commands can be auto-completed.
To get shell completion setup the global default and proceed with these instructions:
For bash:
For zsh:
For fish:
To see the completion script without applying it:
task setup-completion bash # Shows bash completion script
task setup-completion zsh # Shows zsh completion script
task setup-completion fish # Shows fish completion script
The completion also works for the task alias t.
Extend¶
You can extend any Taskfile by add help row and a named bash function.
When developing new commands it's worth to have a look at the patterns page. It gives you an idea of what bash structures can be used and applied.
Docker Image¶
Any project with a Taskfile can be run with the Taskfile Docker image.
See Taskfile Build Image for details.
Integrate¶
Whenever an application uses a domain specific language (DSL) ensure that the DSL-implementation calls a Taskfile command.
GitHub Actions¶
Running Taskfile commands in GitHub Actions is highly recommended. This way you can run the same CI/CD procedures in the GitHub runner as you would on your localhost.
Here is an example for .github/workflows/build.yml:
on:
pull_request:
branches:
- 'main'
push:
branches:
- 'main'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Clone taskfile
run: ./task clone-taskfile
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install
run: ./task install
- name: Lint
run: ./task lint
Jenkins¶
Run Taskfile commands in a Jenkinsfile: