Add support for referencing variables in enum validation:
```yaml
vars:
ALLOWED_ENVS: ["dev", "staging", "prod"]
tasks:
deploy:
requires:
vars:
- name: ENV
enum:
ref: .ALLOWED_ENVS
```
This allows enum values to be defined once and reused, or computed
dynamically using template expressions like `| fromYaml`.
Changes:
- Add Enum type with Ref/Value fields in taskfile/ast/requires.go
- Add resolveEnumRefs() to resolve refs at task compilation time
- Add getEnumValues() helper in requires.go
- Only resolve enum refs when shell variables are evaluated
When using `task FOO=bar` with a Taskfile containing
`FOO: '{{.FOO | default "foo"}}'`, the CLI value was being
overwritten by the Taskfile default.
Split the variable merging into two steps:
1. Merge CLI variables (FOO=bar) first so they override Taskfile vars
2. ReverseMerge special variables (CLI_ARGS, CLI_FORCE, etc.) so
they're available for templating in Taskfile vars
Fixes regression introduced in #2403.
Co-authored-by: Timothy Rule <timothy.rule@gmail.com>
Previously if a task was run as a dependency of another task,
the error message simply reported something like:
exit status 1
It is desirable instead to name the root task and all child tasks in the tree
to the failing task.
After this PR, the error message will read:
task: Failed to run task "root": task: Failed to run task "failing-task": exit status 1
* feat: use TaskTest for executor tests
* feat: more tests
* feat: separate tests for executing and formatting with new functional options that work for both test types
* feat: formatter tests
* refactor: more tests