You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Global vars can't use .CLI_ARGS special var as default value #2090
and the CLI args are set here, I think after the task has been compiled, which means they are not available to any previous global vars which have already been resolved (i.e. this issue):
EDIT:
Could be that the CLI special vars are added to the task.go global vars, after those in the Taskfile and IIRC Vars are evaluated in order which would mean that the global var which references a CLI special var would not evaluate (since that reference would not have been resolved).
these go in after the env vars, but before the global vars ... so those work.
Solution would be to either; relocate the CLI special vars to getSpecialVars() (which might be tricky), or to change the order that the CLI special vars are merged into e.Taskfile.Vars.Merge(globals, nil). I think the former is the better solution, if it could be achieved.
Activity
trulede commentedon Feb 26, 2025
Some of the special vars are set here:
task/compiler.go
Line 199 in b9d202c
and the CLI args are set here, I think after the task has been compiled, which means they are not available to any previous global vars which have already been resolved (i.e. this issue):
task/cmd/task/task.go
Line 220 in b9d202c
EDIT:
Could be that the CLI special vars are added to the task.go global vars, after those in the Taskfile and IIRC Vars are evaluated in order which would mean that the global var which references a CLI special var would not evaluate (since that reference would not have been resolved).
trulede commentedon Feb 28, 2025
This call loads the global vars:
task/cmd/task/task.go
Line 169 in b9d202c
Then this one adds the CLI special vars:
task/cmd/task/task.go
Line 225 in b9d202c
since they are after the global vars, they will not be resolved by the templating (since that is ordered).
Conversely, the other special vars are loaded by the compiler here:
task/compiler.go
Line 49 in b9d202c
these go in after the env vars, but before the global vars ... so those work.
Solution would be to either; relocate the CLI special vars to getSpecialVars() (which might be tricky), or to change the order that the CLI special vars are merged into e.Taskfile.Vars.Merge(globals, nil). I think the former is the better solution, if it could be achieved.