mirror of
https://github.com/go-task/task.git
synced 2026-06-11 09:51:50 +00:00
feat(config): add environment variable support for all taskrc options (#2607)
This commit is contained in:
@@ -355,6 +355,8 @@ remote:
|
||||
- **Type**: `boolean`
|
||||
- **Default**: `false`
|
||||
- **Description**: Allow insecure connections when fetching remote Taskfiles
|
||||
- **CLI equivalent**: `--insecure`
|
||||
- **Environment variable**: `TASK_REMOTE_INSECURE`
|
||||
|
||||
```yaml
|
||||
remote:
|
||||
@@ -366,6 +368,8 @@ remote:
|
||||
- **Type**: `boolean`
|
||||
- **Default**: `false`
|
||||
- **Description**: Work in offline mode, preventing remote Taskfile fetching
|
||||
- **CLI equivalent**: `--offline`
|
||||
- **Environment variable**: `TASK_REMOTE_OFFLINE`
|
||||
|
||||
```yaml
|
||||
remote:
|
||||
@@ -378,6 +382,8 @@ remote:
|
||||
- **Default**: 10s
|
||||
- **Pattern**: `^[0-9]+(ns|us|µs|ms|s|m|h)$`
|
||||
- **Description**: Timeout duration for remote operations (e.g., '30s', '5m')
|
||||
- **CLI equivalent**: `--timeout`
|
||||
- **Environment variable**: `TASK_REMOTE_TIMEOUT`
|
||||
|
||||
```yaml
|
||||
remote:
|
||||
@@ -391,6 +397,8 @@ remote:
|
||||
- **Pattern**: `^[0-9]+(ns|us|µs|ms|s|m|h)$`
|
||||
- **Description**: Cache expiry duration for remote Taskfiles (e.g., '1h',
|
||||
'24h')
|
||||
- **CLI equivalent**: `--expiry`
|
||||
- **Environment variable**: `TASK_REMOTE_CACHE_EXPIRY`
|
||||
|
||||
```yaml
|
||||
remote:
|
||||
@@ -404,7 +412,7 @@ remote:
|
||||
- **Description**: Directory where remote Taskfiles are cached. Can be an
|
||||
absolute path (e.g., `/var/cache/task`) or relative to the Taskfile directory.
|
||||
- **CLI equivalent**: `--remote-cache-dir`
|
||||
- **Environment variable**: `TASK_REMOTE_DIR` (lowest priority)
|
||||
- **Environment variable**: `TASK_REMOTE_CACHE_DIR`
|
||||
|
||||
```yaml
|
||||
remote:
|
||||
@@ -418,6 +426,7 @@ remote:
|
||||
- **Description**: List of trusted hosts for remote Taskfiles. Hosts in this
|
||||
list will not prompt for confirmation when downloading Taskfiles
|
||||
- **CLI equivalent**: `--trusted-hosts`
|
||||
- **Environment variable**: `TASK_REMOTE_TRUSTED_HOSTS` (comma-separated)
|
||||
|
||||
```yaml
|
||||
remote:
|
||||
|
||||
@@ -10,8 +10,8 @@ outline: deep
|
||||
Task has multiple ways of being configured. These methods are parsed, in
|
||||
sequence, in the following order with the highest priority last:
|
||||
|
||||
- [Environment variables](./environment.md)
|
||||
- [Configuration files](./config.md)
|
||||
- [Environment variables](./environment.md)
|
||||
- _Command-line flags_
|
||||
|
||||
In this document, we will look at the last of the three options, command-line
|
||||
@@ -104,6 +104,9 @@ task --version
|
||||
|
||||
Enable verbose mode for detailed output.
|
||||
|
||||
- **Config equivalent**: [`verbose`](./config.md#verbose)
|
||||
- **Environment variable**: [`TASK_VERBOSE`](./environment.md#task-verbose)
|
||||
|
||||
```bash
|
||||
task build --verbose
|
||||
```
|
||||
@@ -112,6 +115,9 @@ task build --verbose
|
||||
|
||||
Disable command echoing.
|
||||
|
||||
- **Config equivalent**: [`silent`](./config.md#silent)
|
||||
- **Environment variable**: [`TASK_SILENT`](./environment.md#task-silent)
|
||||
|
||||
```bash
|
||||
task deploy --silent
|
||||
```
|
||||
@@ -121,6 +127,9 @@ task deploy --silent
|
||||
Disable fuzzy matching for task names. When enabled, Task will not suggest
|
||||
similar task names when you mistype a task name.
|
||||
|
||||
- **Config equivalent**: [`disable-fuzzy`](./config.md#disable-fuzzy)
|
||||
- **Environment variable**: [`TASK_DISABLE_FUZZY`](./environment.md#task-disable-fuzzy)
|
||||
|
||||
```bash
|
||||
task buidl --disable-fuzzy
|
||||
# Output: Task "buidl" does not exist
|
||||
@@ -133,6 +142,9 @@ task buidl --disable-fuzzy
|
||||
|
||||
Stop executing dependencies as soon as one of them fails.
|
||||
|
||||
- **Config equivalent**: [`failfast`](./config.md#failfast)
|
||||
- **Environment variable**: [`TASK_FAILFAST`](./environment.md#task-failfast)
|
||||
|
||||
```bash
|
||||
task build --failfast
|
||||
```
|
||||
@@ -149,6 +161,8 @@ task build --force
|
||||
|
||||
Compile and print tasks without executing them.
|
||||
|
||||
- **Environment variable**: [`TASK_DRY`](./environment.md#task-dry)
|
||||
|
||||
```bash
|
||||
task deploy --dry
|
||||
```
|
||||
@@ -165,6 +179,9 @@ task test lint --parallel
|
||||
|
||||
Limit the number of concurrent tasks. Zero means unlimited.
|
||||
|
||||
- **Config equivalent**: [`concurrency`](./config.md#concurrency)
|
||||
- **Environment variable**: [`TASK_CONCURRENCY`](./environment.md#task-concurrency)
|
||||
|
||||
```bash
|
||||
task test --concurrency 4
|
||||
```
|
||||
@@ -241,6 +258,9 @@ task test --output group --output-group-error-only
|
||||
|
||||
Control colored output. Enabled by default.
|
||||
|
||||
- **Config equivalent**: [`color`](./config.md#color)
|
||||
- **Environment variable**: [`TASK_COLOR`](./environment.md#task-color)
|
||||
|
||||
```bash
|
||||
task build --color=false
|
||||
# or use environment variable
|
||||
@@ -311,6 +331,8 @@ task build --watch --interval 1s
|
||||
|
||||
Automatically answer "yes" to all prompts.
|
||||
|
||||
- **Environment variable**: [`TASK_ASSUME_YES`](./environment.md#task-assume-yes)
|
||||
|
||||
```bash
|
||||
task deploy --yes
|
||||
```
|
||||
@@ -324,6 +346,8 @@ Task automatically detects non-TTY environments (like CI pipelines) and skips
|
||||
prompts. This flag can also be set in `.taskrc.yml` to enable prompts by
|
||||
default.
|
||||
|
||||
- **Environment variable**: [`TASK_INTERACTIVE`](./environment.md#task-interactive)
|
||||
|
||||
```bash
|
||||
task deploy --interactive
|
||||
```
|
||||
|
||||
@@ -10,11 +10,11 @@ outline: deep
|
||||
Task has multiple ways of being configured. These methods are parsed, in
|
||||
sequence, in the following order with the highest priority last:
|
||||
|
||||
- [Environment variables](./environment.md)
|
||||
- _Configuration files_
|
||||
- [Environment variables](./environment.md)
|
||||
- [Command-line flags](./cli.md)
|
||||
|
||||
In this document, we will look at the second of the three options, configuration
|
||||
In this document, we will look at the first of the three options, configuration
|
||||
files.
|
||||
|
||||
## File Precedence
|
||||
@@ -86,17 +86,31 @@ experiments:
|
||||
- **Default**: `false`
|
||||
- **Description**: Enable verbose output for all tasks
|
||||
- **CLI equivalent**: [`-v, --verbose`](./cli.md#-v---verbose)
|
||||
- **Environment variable**: [`TASK_VERBOSE`](./environment.md#task-verbose)
|
||||
|
||||
```yaml
|
||||
verbose: true
|
||||
```
|
||||
|
||||
### `silent`
|
||||
|
||||
- **Type**: `boolean`
|
||||
- **Default**: `false`
|
||||
- **Description**: Disables echoing of commands
|
||||
- **CLI equivalent**: [`-s, --silent`](./cli.md#-s---silent)
|
||||
- **Environment variable**: [`TASK_SILENT`](./environment.md#task-silent)
|
||||
|
||||
```yaml
|
||||
silent: true
|
||||
```
|
||||
|
||||
### `color`
|
||||
|
||||
- **Type**: `boolean`
|
||||
- **Default**: `true`
|
||||
- **Description**: Enable colored output. Colors are automatically enabled in CI environments (`CI=true`).
|
||||
- **CLI equivalent**: [`-c, --color`](./cli.md#-c---color)
|
||||
- **Environment variable**: [`TASK_COLOR`](./environment.md#task-color)
|
||||
|
||||
```yaml
|
||||
color: false
|
||||
@@ -108,6 +122,7 @@ color: false
|
||||
- **Default**: `false`
|
||||
- **Description**: Disable fuzzy matching for task names. When enabled, Task will not suggest similar task names when you mistype a task name.
|
||||
- **CLI equivalent**: [`--disable-fuzzy`](./cli.md#--disable-fuzzy)
|
||||
- **Environment variable**: [`TASK_DISABLE_FUZZY`](./environment.md#task-disable-fuzzy)
|
||||
|
||||
```yaml
|
||||
disable-fuzzy: true
|
||||
@@ -119,6 +134,7 @@ disable-fuzzy: true
|
||||
- **Minimum**: `1`
|
||||
- **Description**: Number of concurrent tasks to run
|
||||
- **CLI equivalent**: [`-C, --concurrency`](./cli.md#-c---concurrency-number)
|
||||
- **Environment variable**: [`TASK_CONCURRENCY`](./environment.md#task-concurrency)
|
||||
|
||||
```yaml
|
||||
concurrency: 4
|
||||
@@ -129,7 +145,8 @@ concurrency: 4
|
||||
- **Type**: `boolean`
|
||||
- **Default**: `false`
|
||||
- **Description**: Stop executing dependencies as soon as one of them fail
|
||||
- **CLI equivalent**: [`-F, --failfast`](./cli.md#f-failfast)
|
||||
- **CLI equivalent**: [`-F, --failfast`](./cli.md#-f---failfast)
|
||||
- **Environment variable**: [`TASK_FAILFAST`](./environment.md#task-failfast)
|
||||
|
||||
```yaml
|
||||
failfast: true
|
||||
@@ -156,6 +173,7 @@ Here's a complete example of a `.taskrc.yml` file with all available options:
|
||||
```yaml
|
||||
# Global settings
|
||||
verbose: true
|
||||
silent: false
|
||||
color: true
|
||||
disable-fuzzy: false
|
||||
concurrency: 2
|
||||
|
||||
@@ -9,16 +9,78 @@ outline: deep
|
||||
Task has multiple ways of being configured. These methods are parsed, in
|
||||
sequence, in the following order with the highest priority last:
|
||||
|
||||
- _Environment variables_
|
||||
- [Configuration files](./config.md)
|
||||
- _Environment variables_
|
||||
- [Command-line flags](./cli.md)
|
||||
|
||||
In this document, we will look at the first of the three options, environment
|
||||
In this document, we will look at the second of the three options, environment
|
||||
variables. All Task-specific variables are prefixed with `TASK_` and override
|
||||
their configuration file equivalents.
|
||||
|
||||
## Variables
|
||||
|
||||
All [configuration file options](./config.md) can also be set via environment
|
||||
variables. The priority order is: CLI flags > environment variables > config files > defaults.
|
||||
|
||||
### `TASK_VERBOSE`
|
||||
|
||||
- **Type**: `boolean` (`true`, `false`, `1`, `0`)
|
||||
- **Default**: `false`
|
||||
- **Description**: Enable verbose output for all tasks
|
||||
- **Config equivalent**: [`verbose`](./config.md#verbose)
|
||||
|
||||
### `TASK_SILENT`
|
||||
|
||||
- **Type**: `boolean` (`true`, `false`, `1`, `0`)
|
||||
- **Default**: `false`
|
||||
- **Description**: Disables echoing of commands
|
||||
- **Config equivalent**: [`silent`](./config.md#silent)
|
||||
|
||||
### `TASK_COLOR`
|
||||
|
||||
- **Type**: `boolean` (`true`, `false`, `1`, `0`)
|
||||
- **Default**: `true`
|
||||
- **Description**: Enable colored output
|
||||
- **Config equivalent**: [`color`](./config.md#color)
|
||||
|
||||
### `TASK_DISABLE_FUZZY`
|
||||
|
||||
- **Type**: `boolean` (`true`, `false`, `1`, `0`)
|
||||
- **Default**: `false`
|
||||
- **Description**: Disable fuzzy matching for task names
|
||||
- **Config equivalent**: [`disable-fuzzy`](./config.md#disable-fuzzy)
|
||||
|
||||
### `TASK_CONCURRENCY`
|
||||
|
||||
- **Type**: `integer`
|
||||
- **Description**: Limit number of tasks to run concurrently
|
||||
- **Config equivalent**: [`concurrency`](./config.md#concurrency)
|
||||
|
||||
### `TASK_FAILFAST`
|
||||
|
||||
- **Type**: `boolean` (`true`, `false`, `1`, `0`)
|
||||
- **Default**: `false`
|
||||
- **Description**: When running tasks in parallel, stop all tasks if one fails
|
||||
- **Config equivalent**: [`failfast`](./config.md#failfast)
|
||||
|
||||
### `TASK_DRY`
|
||||
|
||||
- **Type**: `boolean` (`true`, `false`, `1`, `0`)
|
||||
- **Default**: `false`
|
||||
- **Description**: Compiles and prints tasks in the order that they would be run, without executing them
|
||||
|
||||
### `TASK_ASSUME_YES`
|
||||
|
||||
- **Type**: `boolean` (`true`, `false`, `1`, `0`)
|
||||
- **Default**: `false`
|
||||
- **Description**: Assume "yes" as answer to all prompts
|
||||
|
||||
### `TASK_INTERACTIVE`
|
||||
|
||||
- **Type**: `boolean` (`true`, `false`, `1`, `0`)
|
||||
- **Default**: `false`
|
||||
- **Description**: Prompt for missing required variables
|
||||
|
||||
### `TASK_TEMP_DIR`
|
||||
|
||||
Defines the location of Task's temporary directory which is used for storing
|
||||
@@ -34,18 +96,6 @@ Valid values are `true` (`1`) or `false` (`0`). By default, this is `true` on
|
||||
Windows and `false` on other operating systems. We might consider making this
|
||||
enabled by default on all platforms in the future.
|
||||
|
||||
### `TASK_REMOTE_DIR`
|
||||
|
||||
Defines the location of Task's remote temporary directory which is used for
|
||||
caching remote files. Can be relative like `tmp/task` or absolute like
|
||||
`/tmp/.task` or `~/.task`. Relative paths are relative to the root Taskfile, not
|
||||
the working directory. Defaults to: `./.task`.
|
||||
|
||||
### `TASK_OFFLINE`
|
||||
|
||||
Set the `--offline` flag through the environment variable. Only for remote
|
||||
experiment. CLI flag `--offline` takes precedence over the env variable.
|
||||
|
||||
### `FORCE_COLOR`
|
||||
|
||||
Force color output usage.
|
||||
|
||||
@@ -61,6 +61,11 @@
|
||||
"type": "boolean",
|
||||
"description": "Enable verbose output"
|
||||
},
|
||||
"silent": {
|
||||
"type": "boolean",
|
||||
"description": "Disables echoing",
|
||||
"default": false
|
||||
},
|
||||
"color": {
|
||||
"type": "boolean",
|
||||
"description": "Enable colored output"
|
||||
|
||||
Reference in New Issue
Block a user