Skip to main content

CLI Reference

Task CLI commands have the following syntax:

task [--flags] [tasks...] [-- CLI_ARGS...]
tip

If -- is given, all remaining arguments will be assigned to a special CLI_ARGS variable

Flags​

ShortFlagTypeDefaultDescription
-c--colorbooltrueColored output. Enabled by default. Set flag to false or use NO_COLOR=1 to disable.
-C--concurrencyint0Limit number tasks to run concurrently. Zero means unlimited.
-d--dirstringWorking directorySets directory of execution.
-n--dryboolfalseCompiles and prints tasks in the order that they would be run, without executing them.
-x--exit-codeboolfalsePass-through the exit code of the task command.
-f--forceboolfalseForces execution even when the task is up-to-date.
-g--globalboolfalseRuns global Taskfile, from $HOME/Taskfile.{yml,yaml}.
-h--helpboolfalseShows Task usage.
-i--initboolfalseCreates a new Taskfile.yml in the current folder.
-I--intervalstring5sSets a different watch interval when using --watch, the default being 5 seconds. This string should be a valid Go Duration.
-l--listboolfalseLists tasks with description of current Taskfile.
-a--list-allboolfalseLists tasks with or without a description.
--sortstringdefaultChanges the order of the tasks when listed.
default - Alphanumeric with root tasks first
alphanumeric - Alphanumeric
none - No sorting (As they appear in the Taskfile)
--jsonboolfalseSee JSON Output
-o--outputstringDefault set in the Taskfile or interleavedSets output style: [interleaved/group/prefixed].
--output-group-beginstringMessage template to print before a task's grouped output.
--output-group-endstringMessage template to print after a task's grouped output.
--output-group-error-onlyboolfalseSwallow command output on zero exit code.
-p--parallelboolfalseExecutes tasks provided on command line in parallel.
-s--silentboolfalseDisables echoing.
-y--yesboolfalseAssume "yes" as answer to all prompts.
--statusboolfalseExits with non-zero exit code if any of the given tasks is not up-to-date.
--summaryboolfalseShow summary about a task.
-t--taskfilestringTaskfile.yml or Taskfile.yaml
-v--verboseboolfalseEnables verbose mode.
--versionboolfalseShow Task version.
-w--watchboolfalseEnables watch of the given task.

Exit Codes​

Task will sometimes exit with specific exit codes. These codes are split into three groups with the following ranges:

  • General errors (0-99)
  • Taskfile errors (100-199)
  • Task errors (200-299)

A full list of the exit codes and their descriptions can be found below:

CodeDescription
0Success
1An unknown error occurred
100No Taskfile was found
101A Taskfile already exists when trying to initialize one
102The Taskfile is invalid or cannot be parsed
103A remote Taskfile could not be downloaded
104A remote Taskfile was not trusted by the user
105A remote Taskfile was could not be fetched securely
106No cache was found for a remote Taskfile in offline mode
107No schema version was defined in the Taskfile
200The specified task could not be found
201An error occurred while executing a command inside of a task
202The user tried to invoke a task that is internal
203There a multiple tasks with the same name or alias
204A task was called too many times
205A task was cancelled by the user
206A task was not executed due to missing required variables

These codes can also be found in the repository in errors/errors.go.

info

When Task is run with the -x/--exit-code flag, the exit code of any failed commands will be passed through to the user instead.

JSON Output​

When using the --json flag in combination with either the --list or --list-all flags, the output will be a JSON object with the following structure:

{
"tasks": [
{
"name": "",
"desc": "",
"summary": "",
"up_to_date": false,
"location": {
"line": 54,
"column": 3,
"taskfile": "/path/to/Taskfile.yml"
}
}
// ...
],
"location": "/path/to/Taskfile.yml"
}