Vscode: Task Runner: Provide input parameters

Created on 29 Mar 2016  路  44Comments  路  Source: microsoft/vscode

  • VSCode Version: 0.10.11
  • OS Version: Mac OS X El Capitan

I would like to provide input parameters when a task is executed. How can I accomplish this?

The documentation mentions "variable substitution," which is useful, but a browser search for "param" yields nothing.

Cheers,
Trevor Sullivan
Microsoft MVP: PowerShell

feature-request on-testplan tasks

Most helpful comment

It would be good to be able set an input when calling the task.
Sometimes we need to run a build or even a test that needs some flags or filters as input depending of what we need.

The task caller can prompt for user input after selecting the task (having in task.json like: "argsPrompt": true) or having some predefined arguments to select before running. Or both :)

All 44 comments

This is not supported right now. What would be cool is if you select the task in the quick box if you could provide params there. But this filters right now.

Any progress on this?

No. Nothing has happend here so far.

Any chance this will end up in VSCode anytime in the near future? :)

We want to have a task to switch branches across all of our microservices dynamically based on a text string to allow our QA teams to switch to a develop snapshot. Being able to prompt for that string would be of great use to us.

Also, it will be great if we could define, in _tasks.json_, a list of optional variables something like:

{
  "label": "task with options",
  "type": "shell",
  "command": "command-on-${module}",
  "options": [
    "module1",
    "module2",
    "module3"
  ]
}

Thanks!

+1

+1

Being able to manage low-to-medium complexity workflow operations directly from VSCode would be great.

Certainly would be very beneficial to have this ability!

Launch configurations support to embed variables that can be used to ask for input through the UI.
Please see https://github.com/Microsoft/vscode/issues/30588.

It is not difficult to support the same for tasks (because they share most of the variable implementation anyway).

This is of great interest to me. I work on a CLI project (Angular CLI) and would love to re-use a common debug launch configuration with different arguments.

@weinand I took a look at #30588 and the extension you linked to didn't work for me.

I've also tried to prompt for values using the preLaunchTask option as well with no luck.

@Brocco

Sorry, I'm not the author of the linked extension and I did not read the description thoroughly.

The documentation is outdated: VS Code has changed the syntax for command variables from an ambiguous '.' to a more readable ':'
So instead of ${command.prompt-debug.resolve} please use ${command:prompt-debug.resolve} and it will work fine. I'll file an issue against the extension.

How did you try to prompt for values using the preLaunchTask?
Please note that "tasks" do not support prompting variables; only launch configurations do.

@Brocco could you get the extension to work?

I got it to prompt me, but the entry of the values was confusing and I couldn't get the value I wanted into the launch config.

Admittedly I didn't have a whole lot fo time to play with it and reverted back to my previous workflow for now.

Sorry, but the extension was meant to be an example showing that you can easily support user input for specific work flows.

Just let me know what you need, and I can sketch something up.

It would be good to be able set an input when calling the task.
Sometimes we need to run a build or even a test that needs some flags or filters as input depending of what we need.

The task caller can prompt for user input after selecting the task (having in task.json like: "argsPrompt": true) or having some predefined arguments to select before running. Or both :)

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1

+1
or extension?

+1

+1

+1

+1

+1

+1

I found a solution on Stackoverflow, which works at least for windows:

{
        "label": "runwithargs",
        "type": "shell",
        "windows": {
            "options": {
                "shell": {
                    "executable": "powershell.exe",
                    "args": [
                        "-NoProfile",
                        "-ExecutionPolicy",
                        "Bypass",
                        "-Command"
                    ]
                }
            },
            "command": "",
            "args": [
                { "value": "$cmdargs = read-host 'Enter command line arguments';", "quoting": "weak"},
                { "value": "$morecmdargs = read-host 'Enter more command line arguments';", "quoting": "weak"},
                { "value": "command-to-execute $cmdargs $morecmdargs", "quoting": "weak"}
            ]
        },      
        "presentation": {
            "panel": "dedicated",
            "focus": true
        }
    }

As you can see, it is also possible to prompt for multiple arguments.
The only drawback I noticed so far is, that it tells the definition is not valid. But you can ignore that, it works anyways.

馃憜 the suspense is killing me....

Sorry for my incomplete comment, I was probably on my phone... :smile:

+1

This would be a real good feature for some of the debugging scenarios using vscode we are looking at. Specifically to debug inside docker containers.

@alexr00 Thank you for solving this issue. Is there any documentation on how to use this new feature?

I'll be writing documentation for it this week to link to in the release notes.

Thank you for your effort and the fast response :)

I worked with the new feature on the Insiders build and it looks great, this is really helpful for my workflow, thanks.

Forgive me if I'm being greedy but it would be great to have input "type" option that would let me skip the prompt and use only the "default" value, this way I would not being nagged by the prompt in cases I want this value to be constant.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

biij5698 picture biij5698  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

DovydasNavickas picture DovydasNavickas  路  3Comments

VitorLuizC picture VitorLuizC  路  3Comments

ryan-wong picture ryan-wong  路  3Comments