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

Support single-string args in launch.json #2621

Closed
weikanglim opened this issue Jan 20, 2023 · 7 comments
Closed

Support single-string args in launch.json #2621

weikanglim opened this issue Jan 20, 2023 · 7 comments
Labels
debug/config Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test Debug Issues related to the debugging functionality of the extension. FeatureRequest FrozenDueToAge HelpWanted Issues that are not prioritized by the maintainers. Help is requested from community contributors.

Comments

@weikanglim
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I'd like the ability to create a launch.json that prompts the user for the exact args to be passed through to my debugging program. The user types in the args into the prompt, and the args is passed through to the launching program.

For example, if launching go.exe with debugger, I expect the user to be able to type test ./... in the prompt, and the resulting program go.exe test ./... is ran with debugging:
image

My understanding based on this comment, is that VSCode now allows args to be either a string-array or a string type. However, it is up to the debugging extension to support the newly-added string type.

Desired supported launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceFolder}",
            "console": "integratedTerminal",
            "args": "${input:args}"
        }
    ],
    "inputs": [
        {
            "id": "args",
            "type": "promptString",
            "description": "Args for launch package",
        }
      ]
}

Currently, this configuration results in the following error:
image

Describe the solution you'd like
The string-typed args should be handled to support this scenario.

Describe alternatives you've considered
N/A

Additional context
N/A

@findleyr
Copy link
Contributor

Thanks for the report. This makes sense to me.

@findleyr findleyr added FeatureRequest HelpWanted Issues that are not prioritized by the maintainers. Help is requested from community contributors. labels Jan 26, 2023
@findleyr
Copy link
Contributor

Marking this as HelpWanted as I think it would be reasonable for an external contributor to pick this up.

@findleyr findleyr added Debug Issues related to the debugging functionality of the extension. debug/config Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test labels Jan 26, 2023
@weikanglim
Copy link
Contributor Author

@findleyr I submitted a change for this with tests if anyone on the team would like to take a look. I couldn't find any existing package that provided a shell-like word splitting, ended up implementing one that is consistent with bash / POSIX.

@weikanglim
Copy link
Contributor Author

Hello @findleyr , hope this finds you well. I double checked my changes and tests today, and I like where it is and hope that a maintainer is able to provide review. Would love to be able to take advantage of this feature in my own work/personal projects.

For context, I tried to implement basic whitespace splitting .split(' '), but then with the need to also interpret whitespace as being part of an argument made it more complicated. Perhaps a simple way would have been to provide backslash+whitespace as an escape mechanism, but I wanted to see if we could just make the args string feel familiar to the user, and ended up implementing bash-like semantics for word parsing. I think the tests do give pretty good coverage but would love any feedback on it.

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/469378 mentions this issue: src/goDebugConfiguration.ts: add support for stringtypedargs``

gopherbot pushed a commit that referenced this issue May 15, 2023
This change adds support for user specifying `args` as a single `string`-typed launch argument in `launch.json`.

The argument string is parsed into word arguments with rules consistent with `bash`. No shell expansion is performed.

Fixes [#2621](#2621)

Change-Id: I26d279ac304afa307bf3023ee8835582bb903a05
GitHub-Last-Rev: 3d5cd26
GitHub-Pull-Request: #2670
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/469378
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
@weikanglim
Copy link
Contributor Author

weikanglim commented May 16, 2023

Tested it on nightly today and things work as expected. One of the things I didn't test well was the schema intellisense. It looks like VSCode supports type: ["array", "string"], so we'll want to make a follow-up change to update package.json accordingly. The user gets squiggly lines otherwise when editing launch.json`.

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/495816 mentions this issue: package.json: update launch args schema

@golang golang locked and limited conversation to collaborators May 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug/config Issues for config discrepancies b/n settings.json, launch.json, launch with F5, run test, debug test Debug Issues related to the debugging functionality of the extension. FeatureRequest FrozenDueToAge HelpWanted Issues that are not prioritized by the maintainers. Help is requested from community contributors.
Projects
None yet
3 participants