feat: expose .CLI_ASSUME_YES templating variable by semihbkgr · Pull Request #2577 · go-task/task

This PR exposes the state of the --yes (or -y) CLI flag as a global templating variable named .CLI_ASSUME_YES.

This allows users to conditionally execute logic in their Taskfiles based on whether the user has confirmed prompts via the CLI flag.

see: #2479

Example:

tasks:
  example:
    cmds:
      - >
        {{if .CLI_ASSUME_YES}}
        echo "Assume yes is true"
        {{else}}
        echo "Assume yes is false"
        {{end}}

Changes:

  • Added .CLI_ASSUME_YES to the global variables in cmd/task/task.go
  • Documented the new variable in website/src/docs/reference/templating.md