Skip to content
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

Add support for input variables #224

Open
Jackenmen opened this issue Jul 19, 2023 · 1 comment
Open

Add support for input variables #224

Jackenmen opened this issue Jul 19, 2023 · 1 comment

Comments

@Jackenmen
Copy link

Today I was doing some debugging, changing arguments in the debugger configuration between runs which was a bit of a hassle and I started wondering whether perhaps this is an already solved problem. When doing so, I first found the ${command:SpecifyProgramArgs} option of the VS Code Java extension and opened feature requests for different vs code extensions but since the language I was interested in was not Java and the feature requests weren't pursued, that wasn't really useful.

Pursuing this a bit more, I encountered a feature of VS Code's debugging and task configuration files that solves this problem nicely - input variables. Input variables are substitutions that you can define under "inputs" key in launch.json and later use in e.g. debugger configuration with ${input:variableID}. Then when you launch the debugger with the configuration that requires some inputs, VS Code will prompt you for those variables (either through free text or through a list of options to choose from, depending on input definition), as well as allow you to use its defined default value (if any is provided).

I think that this would be a useful addition to this plugin as well and one of the use cases would be the previously mentioned args argument. Here's how an example launch.json with this options looks ("inputs" key would probably map to "debugger_inputs" in sublime project file):

{
    "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
        }
    ]
}

Note that "args" key specifically can be a string in VS Code since July 2022 (for participating extensions, whatever that means): microsoft/vscode#83678 (comment) This isn't the only use case of course (being able to choose the component to run with inputs could be quite useful too) but I would appreciate if this case could be supported as well if you choose to pursue this.

@daveleroy
Copy link
Owner

daveleroy commented Jul 31, 2023

I probably don't have time for this right now but if its something you want to add support for you are welcome to open a pull request.

This could be useful for some other cases as well like adding a promptPID type that lets the user select a process to attach to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants