Reputation: 1180
What are the best solutions to receive input from user in inputs
vscode on tasks.json
then according chosen option to handle multiple values?
Is there any solution like this bellow?
{
"version": "2.0.0",
"inputs": [
{
"id": "selectProject",
"type": "pickString",
"description": "Some decription",
"options":
[
{
"label": "project1",
"value" : {"path":"","name":"","link":"","anyOther":""} // something like this
} ,
{
"label": "project2",
"value" : {"path":"","name":"","link":"","anyOther":""} // something like this
}
]
}
],
"tasks": [
{
"label": "test on projects",
"type": "process",
"command": "echo",
"args": [
"${input:selectProject.path}", // handle many info from one chosen option
"${input:selectProject.name}",
"${input:selectProject.link}",
"${input:selectProject.anyOther}"
]
}
]
}
currently options can receive only one value :(
"options":
[
{ "label": "project1", "value" : "value" } ,
{ "label": "project2", "value" : "value" }
]
Upvotes: 0
Views: 1822
Reputation: 28763
You can use extension Command Variable v1.22.0.
The command extension.commandvariable.pickStringRemember
can remember multiple values for 1 pick.
The syntax of the label-value is a bit different because I did not know pickString
supported that.
{
"version": "2.0.0",
"tasks": [
{
"label": "Do some project",
"type": "process",
"command": "echo",
"args": [
"${input:selectProject.path}",
"${input:selectProject.name}",
"${input:selectProject.link}",
"${input:selectProject.anyOther}"
],
"problemMatcher": []
}
],
"inputs": [
{
"id": "selectProject.path",
"type": "command",
"command": "extension.commandvariable.pickStringRemember",
"args": {
"key": "path",
"options": [
["project1", {"path":"p1","name":"n1","link":"lnk1","anyOther":"any1"}],
["project2", {"path":"p2","name":"n2","link":"lnk2","anyOther":"any2"}]
],
"description": "Pick a project"
}
},
{
"id": "selectProject.name",
"type": "command",
"command": "extension.commandvariable.rememberPick",
"args": { "key": "name" }
},
{
"id": "selectProject.link",
"type": "command",
"command": "extension.commandvariable.rememberPick",
"args": { "key": "link" }
},
{
"id": "selectProject.anyOther",
"type": "command",
"command": "extension.commandvariable.rememberPick",
"args": { "key": "anyOther" }
}
]
}
Upvotes: 1