-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Allow "args" to be specified as a single string. #1210
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
Comments
Fastest way I can see would be to do a find and replace of You can make it all one string but then its passed to the program as one string and many programs don't like it as one string. We offer this option to allow users the flexibility of specifying separate arguments or arguments with spaces in them. If you want them as one string, you can replace each |
The problem with one string is, as you say, it won’t work for cases where
arguments contain spaces.
Given that “i have a command line, I need to paste it into a json array” is
going to come up repeatedly for many users, what about a Paste Special type
command that just does this? Bind it to Ctrl+Shift+V or something.
…On Wed, Nov 8, 2017 at 6:00 PM Pierson Lee ***@***.***> wrote:
Fastest way I can see would be to do a find and replace of " " with ",".
You can make it all one string but then its passed to the program as one
string and many programs don't like it as one string. We offer this option
to allow users the flexibility of specifying separate arguments or
arguments with spaces in them.
If you want them as one string, you can replace each " with /" and it
will pass it as one string with your quotes.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1210 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ALRpSQhca0chdAjsP2Dn2NRb4mokTBwAks5s0ly1gaJpZM4QUPic>
.
|
I added it as a feature request. I assume we can provide a shortcut but this might be more beneficial to ask VS Code itself to have this feature instead of it only being available for the CPP extension. |
I asked in vscode github and they said to just make an extension. That's about what I expected them to say, but I believe this is useful enough that vscode should support it directly, if not in the larger project in the cpptools extension. Setting a debugging command line is an extremely difficult and awkward thing to do right without it. |
I marked it as a Feature request and we can take a look at what it would take. |
I'd like this to, so that I can specify the args as an input:
|
And also as a configuration parameter:
Not not mention that it's just the canonical way people have been providing program args in shells for decades 😄 |
Has this ever been implemented? It could be flexible and handle both an array (of string) or a single string. |
any status on this? having to separate my 20+ args in comas and quotes is really painful. |
Been bothered by this for years. Might make my own extension. |
I'm working on an extension for this at the moment. |
Done. If anybody is interested @resk8 @zjturner @audetto here's the extension |
I found this thread while trying to resolve this multiple args as single string issue with VS Code's debugger for a node project and I found a kind of hacky solution that seems to work for me, perhaps it can work here as well. I found that the args array always wrapped my string input in a single set of quotes. But by modifying the args line in launch.json to have a closing quote at the start and a closing quote at the end I was able to step out of the quotes altogether and have my input string be added directly as regular bash options. You end up with an empty set of quotes at the start and end of the output in the Debug Console, but that didn't seem to cause any issues on my end.
|
After experimenting with @emaglic 's solution I noticed something. The behaviour of If you use a single string no quoutes are added, if you use an array with spaces in any argument then quotes will be added. Example config:
Array style:
Single string style:
I suspect this isn't intended behaviour as it is inconsistent and undocumented. However, It does allow a single string and it does expand variables like I think a better solution might be to do something like tasks args having the quoting option, but allow us to specify "none" which will stop the adding of quotes.
|
VSCode's launch.json now supports the required feature for non-hacky implementation. The
Info from VSCode team about support:
Without this feature, {
"version": "0.2.0",
"configurations": [
{
"name": "my_program",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/my_program",
"args": [
"${input:arg1}",
"${input:arg2}",
"${input:arg3}",
"${input:arg4}",
],
},
],
"inputs": [
{
"id": "arg1",
"type": "promptString",
"description": "required 1st arg"
},
{
"id": "arg2",
"type": "promptString",
"description": "optional 2nd arg"
},
{
"id": "arg3",
"type": "promptString",
"description": "optional 3rd arg"
},
{
"id": "arg4",
"type": "promptString",
"description": "optional 4th arg"
}
]
} With this feature, {
"version": "0.2.0",
"configurations": [
{
"name": "my_program",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/my_program",
"args": "${input:args}",
},
],
"inputs": [
{
"id": "args",
"type": "promptString",
"description": "space separated args"
},
]
} |
I agree that this is a much needed feature. It would be great to get support for it as it imposes severe limitations on the usability of the launch.json for C++ projects. |
A workaround for now would be to pass the arguments to gdb directly instead of using the launch config's "setupCommands": [
{
"description": "Set command line arguments",
"text": "-gdb-set args ${input:commandLineArgs}",
"ignoreFailures": true
}
] Or if using static text, "setupCommands": [
{
"description": "Set command line arguments",
"text": "-gdb-set args arg1 arg2 arg3 arg4",
"ignoreFailures": true
}
] |
this seems like the answer to me! not a workaround |
I just tried this in version 1.85.1 and it's working now! Make sure you provide a single string with all your args and don't use an array. |
Uh oh!
There was an error while loading. Please reload this page.
When configuring the
launch.json
file, it expectsargs
to be an array of strings that are passed to the process, where each item in the array is one argument. This is extremely user-unfriendly when dealing with long command lines. For example, here is my use case.Problem: I want to debug clang when you run
clang-cl.exe /c foo.cpp
Step 1: Run
clang-cl.exe /c foo.cpp -###
Step 2: Take the resulting command line, and debug that. this is necessary because the original invocation actually spawns a child process whose command line is the second invocation, and it is that child invocation that actually needs to be debugged.
In order for me to do this, I have to manually add commas to this huge list of command line arguments.
Worse, if I change one little option to the original
clang-cl.exe
this entire line could end up being different, and I have to do this all over again. It would be nice if I could just paste this somewhere as a single string.In regular VS there is one box where I can just paste this. Even in GDB I can just run gdb against
clang-cl.exe
and then pass command line arguments as a single string. This is a very big productivity hit for projects that frequently debug processes with long command lines.The text was updated successfully, but these errors were encountered: