I'd like to provide a list of strings as a pickString for a task. The list of strings will be a list of folder names, which I can get from PowerShell, but I'm not sure how to display this list in a task.
How can I set up my task and input so this list can be populated?
{
"version": "2.0.0",
"tasks": [
{
"label": "Test Task",
"type": "shell",
"windows": {
"command": "echo",
"args": [
"-opt",
"${input:optionsList}"
]
}
}
],
"inputs": [
"id": "optionsList",
"type": "pickString",
"options": [<insert something here>]
]
}
I want the user to see the list of folders while the task is running.
Press Ctrl+Shift+B to open a list of tasks in VS Code and select tsc: watch - tsconfig. json . Done! Your project is recompiled on every file save.
${workspaceFolder} - the path of the folder opened in VS Code. ${workspaceFolderBasename} - the name of the folder opened in VS Code without any slashes (/) ${file} - the current opened file.
Set a breakpoint in your code, and start debugging by pressing F5 or selecting Debug > Start Debugging. When paused at the breakpoint, hover over any variable in the current scope. A data tip appears, showing the name and current value of the variable.
Actually VSCode tasks doesn't have this functionality built-in. The enhancement request was closed probably because there is no plans to develop it in the near future.
You can install the augustocdias.tasks-shell-input and configure an input variable with type command
calling this extension for populating the pick list.
Follow the following steps:
Ctrl+Shift+X
) for augustocdias.tasks-shell-input
and install orext install augustocdias.tasks-shell-input
task.json
with:
args
configuration entry one or more references to input variables like ${input:my_variable}
.inputs
section with:
id
: use the same variable name defined in task args
like my_variable
for ${input:my_variable}
type
: command
command
: shellCommand.execute
args
: add an config with the properties: command
, cwd
, env
task.json
file bellow.Example task.json
file using augustocdias.tasks-shell-input
extension:
{
"version": "2.0.0",
"tasks": [
{
"label": "Dynamically Populated Task",
"type": "shell",
"command": "echo",
"args": [
"'${input:my_dynamic_input_variable}'"
],
"problemMatcher": []
}
],
"inputs": [
{
"id": "my_dynamic_input_variable",
"type": "command",
"command": "shellCommand.execute",
"args": {
"command": "ls -1 *.*",
"cwd": "${workspaceFolder}",
"env": {
"WORKSPACE": "${workspaceFolder[0]}",
"FILE": "${file}",
"PROJECT": "${workspaceFolderBasename}"
}
},
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With