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
Allow users to input variables interactively #2079
@andreynering we did something similar for a VSCODE extension where text completion for various tasks is driven by some metadata. The metadata approach is useful as UI elements can be developed independent of the Taskfile schema. You know it under #1916 (an example is here).
Explicitly extending Var to support such interactive use case would also be interesting. But I would suggest something like
vars:
FOO:
prompt: true
required: false
default: {{.FOO}}
desc: BAR
sh: ... this is the existing schema ... so, same technique/constraints
so that we can develop integrations against that. But I still prefer a metadata object ... since its more flexible. No matter what you put in the schema, it will never cover all use cases.
Could using the template engine work? Where a callback interface, from the template function to the UI, allows the retrieval of additional user input. The default UI would be a simple STDIN based prompt. So for example, chaining some template functions:
tasks:
my-task:
vars:
MY_VAR: '{{.MY_OTHER_VAR | prompt "foo"}}'# prompt in "interactive-mode", with default presented to the userMY_VAR2: '{{.MY_OTHER_VAR | prompt "bar" | fail "VAR was not set"}}'# mandatory, must provideMY_VAR3: '{{.MY_OTHER_VAR | prompt | default "fubar"}}'# prompt with no default, then fallback to default for non-interactive casecmds:
- echo "Result: {{.MY_VAR}}"
In interactive mode, prompt returns the value from the callback, or if "Nil", then the "default" prompt value. Otherwise, in non-interactive-mode, prompt returns the "default" prompt value (so acts like default keyword).
Activity
vmaerten commentedon Feb 23, 2025
Really good idea!
Do you want to make all of them interactive, or add a new
interactive: boolflag?andreynering commentedon Feb 23, 2025
@vmaerten Not every variable. I think it makes sense that the user chooses which vars make sense to ask. Perhaps something like this:
or
trulede commentedon Mar 3, 2025
@andreynering we did something similar for a VSCODE extension where text completion for various tasks is driven by some metadata. The metadata approach is useful as UI elements can be developed independent of the Taskfile schema. You know it under #1916 (an example is here).
Explicitly extending Var to support such interactive use case would also be interesting. But I would suggest something like
so that we can develop integrations against that. But I still prefer a metadata object ... since its more flexible. No matter what you put in the schema, it will never cover all use cases.
timrulebosch commentedon May 5, 2025
Could using the template engine work? Where a callback interface, from the template function to the UI, allows the retrieval of additional user input. The default UI would be a simple STDIN based prompt. So for example, chaining some template functions:
In interactive mode, prompt returns the value from the callback, or if "Nil", then the "default" prompt value. Otherwise, in non-interactive-mode, prompt returns the "default" prompt value (so acts like default keyword).
sashokbg commentedon Aug 14, 2025
Hello I have opened an MR that uses bubbletea to list possible choices for vars:
#2379