microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.88k stars 29.16k forks source link

Support for Splitting Input String into Multiple Arguments in launch.json #224859

Closed sammasak closed 3 weeks ago

sammasak commented 2 months ago

Support for Splitting Input String into Multiple Arguments in launch.json

Description

Currently, VS Code's launch.json configuration does not natively support splitting a single input string into multiple arguments for the args array when launching a Python script. This limitation makes it difficult to pass multiple arguments to a script from a single input prompt.

Steps to Reproduce

  1. example app
import typer

app = typer.Typer()

@app.command()
def command1(arg1: str):
    typer.echo(f"Argument 1: {arg1}")

@app.command()
def command1(arg1: str, arg2: str, arg3: str):
    typer.echo(f"Argument 1: {arg1}")
    typer.echo(f"Argument 2: {arg2}")
    typer.echo(f"Argument 3: {arg3}")

if __name__ == "__main__":
    app()
  1. Create a .vscode/launch.json file with the following configuration:

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Run CLI Script",
          "type": "debugpy",
          "request": "launch",
          "program": "cli.main",
          "args": [
            "${input:args}"
          ],
          "console": "integratedTerminal"
        }
      ],
      "inputs": [
        {
          "id": "args",
          "type": "promptString",
          "description": "Enter the args for the task",
          "default": "previous_args"
        }
      ]
    }
  2. When running the above configuration, enter multiple arguments as a single string (e.g., command1 arg1).

  3. Observe that the entire string is passed as a single argument rather than being split into individual arguments.

Expected Behavior

It would be beneficial if launch.json could natively support splitting a single input string into multiple arguments for the args array. For example, when entering arg1 arg2 "arg with spaces" arg4, the arguments should be passed as arg1, arg2, arg with spaces, and arg4 to the script.

Additionally it would be nice to have the default value be dynamic such that you could reuse the latest used args as the default value.

### Tasks
roblourens commented 2 months ago

This would basically be an input that would return multiple values, which is a different type of thing than the existing promptString.

vs-code-engineering[bot] commented 2 months ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

sammasak commented 2 months ago

This would basically be an input that would return multiple values, which is a different type of thing than the existing promptString.

Yes, Would be nice to have one input field that takes in any amount of args, (and then uses the previously ran args as default for the next run).

vs-code-engineering[bot] commented 1 month ago

This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

vs-code-engineering[bot] commented 3 weeks ago

:slightly_frowning_face: In the last 60 days, this feature request has received less than 20 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our documentation.

Happy Coding!