0

I am debugging my code using a launch.json file. I have a long list of command line arguments:

            "args": [
                "-i", "inputfile",
                "-o", "outputfile",
                "--option", "do_stuff",
                "--very-long-option", "do_some_serious_stuff",
                ...
            ]

It works well. But now I would like to run the same program with the same arguments using command prompt:

my_prog -i inputfile -o outputfile --option do_stuff --very-long-option do_some_serious_stuff ...

I can generate this command line manually by editing the data taken from the launch.json file, but it's time-consuming and error-prone. How can I make VSCode print this command line for me each time I debug my program?

I tried adding the following to my tasks.json file:

        {
            "label": "echo_cmd_line",
            "command": "echo",
            "args": ["args are", "${args}"],
            "type": "shell"
        },

and the following to my launch.json file:

        "preLaunchTask": "echo_cmd_line",

but it outputs just args are. Not sure I can access arguments in this way.

How can I make it work?

2 Answers 2

1

perhaps adding something like this -- thanks to https://github.com/microsoft/vscode/issues/201785

--in launch.json

"preLaunchTask": "echo_cmd_line",
"preLaunchTaskInputs": {
  "LaunchArgs": "${args}"
}

--in tasks.json

"args": ["args are", "${LaunchArgs}"],
Sign up to request clarification or add additional context in comments.

1 Comment

Just to make it clear, the method described in this answer doesn't work. This answer is only useful because it contains the link to the relevant issue.
0

This currently seems to be impossible.

As noted by this answer, this feature was requested 7 years ago but not implemented yet, so probably not deemed important enough.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.