1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00
This commit is contained in:
Andrey Nering
2025-01-18 11:15:57 -03:00
parent 0f633091eb
commit a2390d0dca
12 changed files with 340 additions and 212 deletions

View File

@@ -1,6 +1,6 @@
---
slug: /reference/environment
sidebar_position: 4
sidebar_position: 5
---
# Environment Reference

View File

@@ -0,0 +1,29 @@
---
slug: /reference/package
sidebar_position: 2
---
# Package API
:::warning
**_Task's package API is still experimental and subject to breaking changes._**
This means that unlike our CLI, we may make breaking changes to the package API
in minor (or even patch) releases. We try to avoid this when possible, but it
may be necessary in order to improve the overall design of the package API.
In the future we may stabilize the package API. However, this is not currently
planned. For now, if you need to use Task as a Go package, we recommend pinning
the version in your `go.mod` file. Where possible we will try to include a
changelog entry for breaking changes to the package API.
:::
Task is primarily a CLI tool that is agnostic of any programming language.
However, it is written in Go and therefore can also be used as a Go package too.
This can be useful if you are already using Go in your project and you need to
extend Task's functionality in some way.
The full generated documentation for the package API is available on
[pkg.go.dev](https://pkg.go.dev/github.com/go-task/task/v3).

View File

@@ -1,6 +1,6 @@
---
slug: /reference/schema
sidebar_position: 2
sidebar_position: 3
toc_min_heading_level: 2
toc_max_heading_level: 5
---
@@ -140,7 +140,7 @@ tasks:
| `silent` | `bool` | `false` | Skips some output for this command. Note that STDOUT and STDERR of the commands will still be redirected. |
| `vars` | [`map[string]Variable`](#variable) | | Optional additional variables to be passed to the referenced task. Only relevant when setting `task` instead of `cmd`. |
| `ignore_error` | `bool` | `false` | Continue execution if errors happen while executing the command. |
| `defer` | `string` | | Alternative to `cmd`, but schedules the command to be executed at the end of this task instead of immediately. This cannot be used together with `cmd`. |
| `defer` | [`Defer`](#defer) | | Alternative to `cmd`, but schedules the command or a task to be executed at the end of this task instead of immediately. This cannot be used together with `cmd`. |
| `platforms` | `[]string` | All platforms | Specifies which platforms the command should be run on. [Valid GOOS and GOARCH values allowed](https://github.com/golang/go/blob/master/src/internal/syslist/syslist.go). Command will be skipped otherwise. |
| `set` | `[]string` | | Specify options for the [`set` builtin](https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html). |
| `shopt` | `[]string` | | Specify option for the [`shopt` builtin](https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html). |
@@ -180,6 +180,17 @@ tasks:
:::
### Defer
The `defer` parameter defines a shell command to run, or a task to trigger, at the end of the current task instead of immediately.
If defined as a string this is a shell command, otherwise it is a map defining a task to call:
| Attribute | Type | Default | Description |
| --------- | ---------------------------------- | ------- | ----------------------------------------------------------------- |
| `task` | `string` | | The deferred task to trigger. |
| `vars` | [`map[string]Variable`](#variable) | | Optional additional variables to be passed to the deferred task. |
| `silent` | `bool` | `false` | Hides task name and command from output. The command's output will still be redirected to `STDOUT` and `STDERR`. |
### For
The `for` parameter can be defined as a string, a list of strings or a map. If

View File

@@ -1,6 +1,6 @@
---
slug: /reference/templating/
sidebar_position: 3
sidebar_position: 4
toc_min_heading_level: 2
toc_max_heading_level: 5
---
@@ -114,6 +114,7 @@ special variable will be overridden.
| `ROOT_DIR` | The absolute path of the root Taskfile directory. |
| `TASKFILE` | The absolute path of the included Taskfile. |
| `TASKFILE_DIR` | The absolute path of the included Taskfile directory. |
| `TASK_DIR` | The absolute path of the directory where the task is executed. |
| `USER_WORKING_DIR` | The absolute path of the directory `task` was called from. |
| `CHECKSUM` | The checksum of the files listed in `sources`. Only available within the `status` prop and if method is set to `checksum`. |
| `TIMESTAMP` | The date object of the greatest timestamp of the files listed in `sources`. Only available within the `status` prop and if method is set to `timestamp`. |