0

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"  }
            ]
2
  • where have you found that pickString supports label-value pairs Commented Sep 7, 2021 at 3:39
  • I don't know. I'm just using it. It works for me on label-value. May be any extension I have? Commented Sep 9, 2021 at 14:03

1 Answer 1

1

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" }
    }
  ]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.