question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add prompt for arguments when launching debugger

See original GitHub issue

With the java extension for VS Code, when editing launch parameters, you can set args to be "${command:SpecifyProgramArgs}" which will prompt for arguments.

A similar feature for Python would have been most appreciated.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:35
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
noviriumcommented, Feb 3, 2021

This would be very useful if implemented. While we can already use a promptString input in launch.json to allow user input to args when debugging, this is limited to a single argument (as the args value is a list of strings, not one long string, and variable substitution only works within strings).

There has been discussion about this in various places (cpp-tools, js-debug, and vscode itself), and the straightforward solution has been to introduce a new parameter for the debugger in launch.json: argsString. This has been successfully implemented by bash-debug in this PR. The upshot is the content of argsString is parsed by shell-quote, and the resulting array of strings is appended to the normal args parameter.

This would allow users to use a VSCode promptstring input to allow arbitrary command arguments during debug (which would be really useful!) with something like:

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Test CLI (input)",
            "type": "python",
            "request": "launch",
            "module": "mycli",
            "argsString": "${input:argPrompt}"
        },
    ],
    "inputs": [
        {
            "id": "argPrompt",
            "description": "CLI arguments",
            "default": "",
            "type": "promptString"
        }
    ]
}
0reactions
ceusebi-ebcommented, Nov 16, 2022

Not from the team but I stumbled across this and with this snippet:

{
    "version": "0.2.0",
    "inputs": [
        {
            "id": "fileArguments",
            "description": "The arguments to send to the debugger",
            "type": "promptString",
            "default": "",
        }
    ],
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "console": "integratedTerminal",
            "request": "launch",
            "program": "${file}",
            "args": "${input:fileArguments}",
            "justMyCode": true
        }
    ]
}

It is possible to obtain multiple parameters split as you type them image

image

VsCode Version: 1.73.1 Python extension Version: v2022.18.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prompt for specifying arguments when launching debugger
In the Java extension for VS Code, when editing launch parameters, you can set args to be "${command:SpecifyProgramArgs}" which will prompt for ......
Read more >
VS Code debugging prompting for arguments and also setting ...
I know how to pass fixed arguments in the launch.json, e.g. In Visual Studio Code, how to pass arguments in launch.json .
Read more >
Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >
Add Program Arguments and Environment Variables - JetBrains
Type the arguments in the Program arguments field. The arguments should be separated with spaces.
Read more >
How to set-up command line arguments in Microsoft Visual ...
This works when you press F5 to run the code or start a debug session. Alternative to command line arguments. Above I have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found