Skip to content

Prompt for arguments? #844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tomdale opened this issue Oct 24, 2016 · 11 comments
Open

Prompt for arguments? #844

tomdale opened this issue Oct 24, 2016 · 11 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@tomdale
Copy link

tomdale commented Oct 24, 2016

I'm working on a large Node project that's made up of several different packages, each one with a suite of tests. I have a launch.json configuration per package to run each test suite individually. But when I'm trying to debug a single failing test, the overhead of running the entire suite can really slow things down.

In those cases, I go in and manually edit the launch.json and add some arguments to the args field to tell Mocha to only run matching tests with the -g option:

"args": ["--opts", "tests/mocha.opts", "-g", "photos should upload and return a 200 response"],

However, this isn't super discoverable for other people on the team. Ideally, I'd like to make a configuration that prompts the user to provide a string that can be passed as the argument.

I really like how ${command.PickProcess} allows me to create a dynamic configuration with a GUI to prompt me for the process to attach to. Is there any way to do something similar for an argument value? If not, can I humbly submit this as a feature request? 😄

@weinand
Copy link

weinand commented Oct 26, 2016

The mock debugger shows how to ask the user for a string/name from a launch config:
https://github.com/Microsoft/vscode-mock-debug/blob/master/src/extension.ts#L23
The problem is that you cannot (yet) easily use this approach in a launch config without writing that extension code and introducing a 'variable'.
But it is planned to simplify this: microsoft/vscode#12735

@weinand weinand self-assigned this Oct 26, 2016
@weinand
Copy link

weinand commented Nov 30, 2016

Since microsoft/vscode#12735 has been implemented it is now possible to provide "Prompt for Arguments" functionality as an extension and use it in launch.json and task.json.

@weinand weinand closed this as completed Nov 20, 2017
@probert94
Copy link

@weinand Can you give an example of a task (entry of task.json) which uses a prompt to add command arguments?

@VaultDeveloper
Copy link

@weinand Can you ?

@weinand
Copy link

weinand commented Feb 4, 2020

Applying what is said in https://code.visualstudio.com/docs/editor/variables-reference#_input-variables to the example from above:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "run tests",
      "command": "mocha",
      "args": [
         "--opts", "tests/mocha.opts",
         "-g", "'${input:someArgs}'"
       ]
    }
  ],
  "inputs": [
    {
      "id": "someArgs",
      "type": "promptString",
      "description": "enter some arguments"
    }
  ]
}

(I did not verify that this works...)

@marvingreenberg
Copy link

marvingreenberg commented May 5, 2020

I verified that it works -- https://github.com/Microsoft/vscode-node-debug/issues/108#issuecomment-581815593

You can put an inputs section into launch.json, and reference the defined variables in your launch configurations.

Now I want ONE MORE thing - a way to get the OLD arg behavior allowing a space delimited arg string, because I want one generic configuration to debug any old script, like:

   configuration: [
   {
        // This runs the current file as a script with whatever args are typed 
        "type": "node",
        "request": "launch",
        "name": "Launch script",
        "cwd": "${fileDirname}",
        "program": "${file}",
        "args": "${input:argValues}",      // <== This doesn't work because this must be a list
        "skipFiles": [ "<node_internals>/**" ]
    },

With an input section as above with "id": "argValues"

@weinand
Copy link

weinand commented May 5, 2020

@marvingreenberg your ONE MORE thing is covered by this feature request: microsoft/vscode#83678

@marvingreenberg
Copy link

marvingreenberg commented May 5, 2020 via email

@weinand
Copy link

weinand commented May 5, 2020

@marvingreenberg I just noticed that this issue lives in the "vscode-node-debug" repository and not "vscode", so it does not ask for a generic VS Code solution (which is not feasible for the reasons explained in length in microsoft/vscode#83678).

What you suggest is actually possible in a specific extension: node-debug could support an alternative argString property that takes a command-line-like string and parses it into the array args. This could even take place in the extension outside of the debug adapter.

/cc @connor4312 for js-debug

@weinand weinand reopened this May 5, 2020
@marvingreenberg
Copy link

marvingreenberg commented May 5, 2020

I don't want to comment too much in what is obviously the wrong place (as my earlier comment was) I apologize - and I see that 83678 is not closed permanently. Oh, but I can't comment Over there. I'm definitely +1 on @weinand suggestion to inject (e.g.) _args for string array - it is creative and provides a good appraoch for differnt uses including inputs: {

@weinand
Copy link

weinand commented May 5, 2020

@marvingreenberg I've unlocked microsoft/vscode#83678

@connor4312 connor4312 transferred this issue from microsoft/vscode-node-debug Nov 5, 2020
@connor4312 connor4312 assigned connor4312 and unassigned weinand Nov 5, 2020
@connor4312 connor4312 added the feature-request Request for new features or functionality label Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

6 participants