Giter VIP home page Giter VIP logo

Comments (11)

probert94 avatar probert94 commented on May 10, 2024 9

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

from vscode-js-debug.

weinand avatar weinand commented on May 10, 2024 8

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...)

from vscode-js-debug.

marvingreenberg avatar marvingreenberg commented on May 10, 2024 1

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"

from vscode-js-debug.

marvingreenberg avatar marvingreenberg commented on May 10, 2024 1

from vscode-js-debug.

weinand avatar weinand commented on May 10, 2024

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

from vscode-js-debug.

weinand avatar weinand commented on May 10, 2024

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.

from vscode-js-debug.

VaultDeveloper avatar VaultDeveloper commented on May 10, 2024

@weinand Can you ?

from vscode-js-debug.

weinand avatar weinand commented on May 10, 2024

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

from vscode-js-debug.

weinand avatar weinand commented on May 10, 2024

@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

from vscode-js-debug.

marvingreenberg avatar marvingreenberg commented on May 10, 2024

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: {

from vscode-js-debug.

weinand avatar weinand commented on May 10, 2024

@marvingreenberg I've unlocked microsoft/vscode#83678

from vscode-js-debug.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.