Reputation: 172
I found myself retyping the same value in pickStrings' options way too many times. Unfortunately, I need to have multiple inputs that have the same value but with different descriptions, hence the appearance of the same values.
For example:
{
"version": "2.0.0",
"tasks": [
{
"label": "Deploy",
"type": "shell",
"options": {
"cwd": "${workspaceRoot}"
},
"command": "scp *path-to-my-bin* user@${input:IP_to_deploy}"
},
{
label": "Restart Remote",
"type": "shell",
"options": {
"cwd": "${workspaceRoot}"
},
"command": "ssh user@{input:IP_to_restart} restart.sh", // I could use IP_to_deploy but then the description would be wrong
}
],
"inputs":
[
{
"id": "IP_to_deploy",
"description": "Where to deploy your binary",
"options":
[
"xxx.xxx.xxx.xxx",
"xxx.xxx.yyy.yyy"
],
"type": "pickString"
},
{
"id": "IP_to_restart",
"description": "What machine to restart",
"options":
[
"xxx.xxx.xxx.xxx",
"xxx.xxx.yyy.yyy"
],
"type": "pickString"
}
]
}
Of course I could write a "description" like "description": "Where to deploy your binary/What machine to restart/one more/and another one/etc.." but this is far from what I wanted.
But also consider maintainability: if, for example, the IPs change, I have to make a lot of changes, while with contansts it'd be virtually instantaneous.
All of this comes from the fact that I'm preparing these tasks for my team, so I'd like to be as precise as possible with the description to avoid confusion. Consider that the team is going to expand in the near feature, so having the right descriptions in place will definitely be beneficial for new comers.
So what I'd like to do/see would be something like the following
{
"version": "2.0.0",
"tasks": [
// some tasks
],
"inputs":[
{
"id": "IP_to_deploy",
"description": "Where to deploy your binary",
"options":
[
"${constant:IP1}",
"${constant:IP2}"
],
"type": "pickString"
},
{
"id": "IP_to_restart",
"description": "What machine to restart",
"options":
[
"${constant:IP1}",
"${constant:IP2}"
],
"type": "pickString"
}
],
"constants":[
{
"name": "IP1",
"value": "the-ip-we-care-about1"
},
{
"name": "IP1",
"value": "the-ip-we-care-about2"
}
]
}
Is there anything that I could do to achieve that behaviour?
N.B. Consider what I wrote in the examples as a simple stuff just for the purpose of showing what I meant. Please, don't take this question as "trying to remove duplication of just 2 strings" in 2 tasks/inputs. The real case scenario is way more complex.
Upvotes: 2
Views: 1087
Reputation: 1326776
This might be less of a problem with VSCode 1.42 (Q1 2020) and its Input pickString label:
If you use task
inputs
, you can add a friendlylabel
topickString
options:"inputs": [ { "id": "pickAnInputValue", "description": "Pick a Value", "type": "pickString", "options": [ "first-value", { "label": "Second Value", "value": "second-long-value-that-can-be-simplified-for-display" } ], "default": "first-value" } ]
This will show as:
Upvotes: 3