mirror of
https://github.com/go-task/task.git
synced 2026-07-01 00:24:30 +00:00
feat: configure output flags via environment variables (#2873)
Co-authored-by: Or Carmi <ocarmi@paloaltonetworks.com> Co-authored-by: Valentin Maerten <maerten.valentin@gmail.com>
This commit is contained in:
@@ -143,10 +143,10 @@ func init() {
|
||||
pflag.BoolVarP(&ExitCode, "exit-code", "x", false, "Pass-through the exit code of the task command.")
|
||||
pflag.StringVarP(&Dir, "dir", "d", "", "Sets the directory in which Task will execute and look for a Taskfile.")
|
||||
pflag.StringVarP(&Entrypoint, "taskfile", "t", "", `Choose which Taskfile to run. Defaults to "Taskfile.yml".`)
|
||||
pflag.StringVarP(&Output.Name, "output", "o", "", "Sets output style: [interleaved|group|prefixed].")
|
||||
pflag.StringVar(&Output.Group.Begin, "output-group-begin", "", "Message template to print before a task's grouped output.")
|
||||
pflag.StringVar(&Output.Group.End, "output-group-end", "", "Message template to print after a task's grouped output.")
|
||||
pflag.BoolVar(&Output.Group.ErrorOnly, "output-group-error-only", false, "Swallow output from successful tasks.")
|
||||
pflag.StringVarP(&Output.Name, "output", "o", getConfig(config, "OUTPUT", func() *string { return nil }, ""), "Sets output style: [interleaved|group|prefixed].")
|
||||
pflag.StringVar(&Output.Group.Begin, "output-group-begin", getConfig(config, "OUTPUT_GROUP_BEGIN", func() *string { return nil }, ""), "Message template to print before a task's grouped output.")
|
||||
pflag.StringVar(&Output.Group.End, "output-group-end", getConfig(config, "OUTPUT_GROUP_END", func() *string { return nil }, ""), "Message template to print after a task's grouped output.")
|
||||
pflag.BoolVar(&Output.Group.ErrorOnly, "output-group-error-only", getConfig(config, "OUTPUT_GROUP_ERROR_ONLY", func() *bool { return nil }, false), "Swallow output from successful tasks.")
|
||||
pflag.BoolVarP(&Color, "color", "c", getConfig(config, "COLOR", func() *bool { return config.Color }, true), "Colored output. Enabled by default. Set flag to false or use NO_COLOR=1 to disable.")
|
||||
pflag.IntVarP(&Concurrency, "concurrency", "C", getConfig(config, "CONCURRENCY", func() *int { return config.Concurrency }, 0), "Limit number of tasks to run concurrently.")
|
||||
pflag.DurationVarP(&Interval, "interval", "I", 0, "Interval to watch for changes.")
|
||||
|
||||
@@ -226,6 +226,8 @@ task backup --global
|
||||
|
||||
Set output style. Available modes: `interleaved`, `group`, `prefixed`.
|
||||
|
||||
- **Environment variable**: [`TASK_OUTPUT`](./environment.md#task-output)
|
||||
|
||||
```bash
|
||||
task test --output group
|
||||
```
|
||||
@@ -234,6 +236,8 @@ task test --output group
|
||||
|
||||
Message template to print before grouped output.
|
||||
|
||||
- **Environment variable**: [`TASK_OUTPUT_GROUP_BEGIN`](./environment.md#task-output-group-begin)
|
||||
|
||||
```bash
|
||||
task test --output group --output-group-begin "::group::{{.TASK}}"
|
||||
```
|
||||
@@ -242,6 +246,8 @@ task test --output group --output-group-begin "::group::{{.TASK}}"
|
||||
|
||||
Message template to print after grouped output.
|
||||
|
||||
- **Environment variable**: [`TASK_OUTPUT_GROUP_END`](./environment.md#task-output-group-end)
|
||||
|
||||
```bash
|
||||
task test --output group --output-group-end "::endgroup::"
|
||||
```
|
||||
@@ -250,6 +256,8 @@ task test --output group --output-group-end "::endgroup::"
|
||||
|
||||
Only show command output on non-zero exit codes.
|
||||
|
||||
- **Environment variable**: [`TASK_OUTPUT_GROUP_ERROR_ONLY`](./environment.md#task-output-group-error-only)
|
||||
|
||||
```bash
|
||||
task test --output group --output-group-error-only
|
||||
```
|
||||
|
||||
@@ -81,6 +81,34 @@ variables. The priority order is: CLI flags > environment variables > config fil
|
||||
- **Default**: `false`
|
||||
- **Description**: Prompt for missing required variables
|
||||
|
||||
### `TASK_OUTPUT`
|
||||
|
||||
- **Type**: `string` (`interleaved`, `group`, `prefixed`)
|
||||
- **Description**: Sets the output style
|
||||
- **CLI equivalent**: [`--output`](./cli.md#--output-string)
|
||||
|
||||
### `TASK_OUTPUT_GROUP_BEGIN`
|
||||
|
||||
- **Type**: `string`
|
||||
- **Description**: Message template to print before a task's grouped output.
|
||||
Only applies when the output style is `group`.
|
||||
- **CLI equivalent**: [`--output-group-begin`](./cli.md#--output-group-begin-template)
|
||||
|
||||
### `TASK_OUTPUT_GROUP_END`
|
||||
|
||||
- **Type**: `string`
|
||||
- **Description**: Message template to print after a task's grouped output.
|
||||
Only applies when the output style is `group`.
|
||||
- **CLI equivalent**: [`--output-group-end`](./cli.md#--output-group-end-template)
|
||||
|
||||
### `TASK_OUTPUT_GROUP_ERROR_ONLY`
|
||||
|
||||
- **Type**: `boolean` (`true`, `false`, `1`, `0`)
|
||||
- **Default**: `false`
|
||||
- **Description**: Swallow output from successful tasks. Only applies when the
|
||||
output style is `group`.
|
||||
- **CLI equivalent**: [`--output-group-error-only`](./cli.md#--output-group-error-only)
|
||||
|
||||
### `TASK_TEMP_DIR`
|
||||
|
||||
Defines the location of Task's temporary directory which is used for storing
|
||||
|
||||
Reference in New Issue
Block a user