Support for single string args in launch.json to expand to multiple arguments
Is your feature request related to a problem? Please describe. I would like to prompt the developer to input the "args" that need to be sent to my dart application on startup. It would be best if the developer only received a single prompt line. Multiple plugins seem to already have implemented this solution in the following way:
{
"configurations": [
{
"args": "hello this is me",
}
]
}
Eventually I would like to be able to do
{
"configurations": [
{
"args": "${commandline}",
}
],
"inputs": [
{
"id": "commandline",
"type": "promptString",
}
]
}
See also these links: https://github.com/microsoft/vscode/issues/83678#issuecomment-1236381454 https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_70.md#javascript-debugging
Describe the solution you'd like To implement a similar implementation as the javascript extension.
Describe alternatives you've considered
The alternative is to copy-paste my configuration for 1, 2, 3, 4, 5... arguments so that it is possible to prompt the user per argument. That would make a lot of switches in the launch file.
{
"configurations": [
{
"args": ["${arg0}"],
},
{
"args": ["${arg0}", "${arg1}"],
}
],
"inputs": [
{
"id": "arg0",
"type": "promptString",
},
{
"id": "arg1",
"type": "promptString",
}
]
}
Are you trying to use this for Dart or Flutter?
The item you linked for JS debugging is specific to when using the debug adapter's runInTerminal request. It only works if the args are being sent to a shell where they can be interpreted by the shell. This is something that is not supported by Flutter (the debug adapter needs to own the process, so cannot delegate spawning it to VS Code), and it's not the default for Dart (although you can enable it with the cliConsole setting and related launch config option).
Perhaps there's a better way to achieve what you're after - can you expand on the specific things you'd like to use this for?
I am working on a dart console application. It runs natively in windows/linux/macos. I tried to set the console to "terminal", "externalTerminal", "debugConsole" in my launch.json.
Here is my full launch.json file. As you can see, I don't want to copy this full configuration for every new parameter set I want to debug. And I also don't want to change my launch file every time on testing. I thought it would be a good idea to prompt the developer on startup.
{
"version": "0.2.0",
"configurations": [
{
"name": "start cli",
"request": "launch",
"type": "dart",
"windows": {
"name": "start cli",
"request": "launch",
"type": "dart",
"env": {
"LIBSERIALPORT_PATH": "${workspaceFolder:device-client}/third_party/libserialport/windows/serialport.dll"
}
},
"osx": {
"name": "start cli",
"request": "launch",
"type": "dart",
"env": {
"LIBSERIALPORT_PATH": "${workspaceFolder:device-client}/third_party/libserialport/macos/libserialport.dylib"
}
},
"linux": {
"name": "start cli",
"request": "launch",
"type": "dart",
"env": {
"LIBSERIALPORT_PATH": "${workspaceFolder:device-client}/third_party/libserialport/linux/libserialport.so"
}
},
"toolArgs": [
"--define=ENV=dev",
"--define=LOG_LEVEL=info",
"--define=DEV_MODE=true",
],
"args": "${input:cli_cmd}",
"program": "${workspaceFolder:cli}/bin/cmdline.dart",
},
],
"inputs": [
{
"id": "cli_cmd",
"type": "promptString",
"description": "The command to call on the cli.",
"default": "version"
},
]
}
Another option I tried was to use a picker, but that still resolves to a single string, and not a list of strings to pass directly to args.
Thanks for the clarification. Since this is Dart CLI then it may be possible to support (although it would be specifically only Dart, and only when using the terminal execution modes).