Closed hoon0422 closed 2 years ago
@hoon0422 thank you for your pitch! I've added an option to change serialization.
You can use serializer
option with value plain
. Your multiple options will be passed to your executable with a space delimeter.
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Launch Program",
"skipFiles": ["<node_internals>/**"],
"args": ["${input:myDynamicParameter}"],
"program": "${workspaceFolder}/main.js",
"preLaunchTask": "myPreBuildTask"
}
],
"inputs": [
{
"id": "myDynamicParameter",
"type": "command",
"command": "dynamic-inputs.write",
"args": {
"command": "bash",
"args": ["${workspaceFolder}/populate.sh"],
"var": "myDynamicParameter",
"unwrap": "$[*].value",
"serializer": "plain", // this is an option to control
"quickPickOptions": {
"canPickMany": true,
"ignoreFocusOut": true,
"placeHolder": "Please select an option",
"title": "Parameter"
}
}
}
]
}
It's available in v0.0.13
Thanks for the reply! I checked and tried the newest version, but there are some issues. There are double quotes encompassing each selected value on the output with a space delimiter. I think the reason is JSON.stringify
on this line. Due to this, for example, if I selected A
and B
from ["A", "B"]
(and those selection appears without double quotes), the output shows "\"A\""
and "\"B\""
on bash command. The result that I want is just a plain A
and B
.
By the way, I think that your solution is nice, but I also think that it is good to give customization options, like my way or the way passing the selected options to the user-specified script as a system argument for parsing. For example, there might be a project that uses CSV severely, which might need a comma delimiter.
I'm afraid we can't achieve the desired behaviour due to how vscode handles args
. I can confirm that the changes in the PR will not make vscode capture multiple selections as multiple arguments.
{
"version": "0.2.0",
"configurations": [
{
// ...
"args": ["${input:myDynamicParameter}"] // <-- vscode always separates arguments with quotes
// ...
}
]
}
The resolved config will look like the following:
{
"version": "0.2.0",
"configurations": [
{
// ...
"args": ["A B"] // <-- vscode always separates arguments with quotes
// ...
}
]
}
And the executable will receive it like
echo 'A B' # <-- a single argument
# desired but not possible
echo 'A' 'B'
Actually, if launch.json
looks like:
{
"version": "0.2.0",
"configurations": [
{
// ...
"args": ["A B"] // <-- vscode always separates arguments with quotes
// ...
}
]
}
then the executable receives it like:
echo A B
not
echo 'A B'
So I guess, because of JSON.stringify
on plain
serializer, the args
in launch.json
seems to be like "args": ["\"A B\""]
, which is not desired.
@hoon0422 removed JSON.stringify
. All values will be passed as is. Released v0.0.14
I would like to use this extension with more options about the output string, so I add them to this request.
New options:
parse
User can simply add
parse
tolaunch.json
like other options. I wrote how to use them and the example of them on README.md, so please refer to it.Why these options are needed
I was doing Django project, and what I want to do was to write the below command for testing:
So what I tried is (1) to write a shell script to get all the test files and (2) to create
launch.json
that allows a user to select test modules to run from VSCode prompt. I createdlaunch.json
that works for (1) and (2). However, since the only format of the output string was JSON, I could not make a string liketest app.tests.unit.test_first_module app.tests.unit.test_second_module app.tests.unit.test_third_module
, whose delimiter is a space character.With my parser option, I can create any string format I want to.