So obviously there are arguments for commands and registering a command like
vscode.commands.registerCommand("bla", (arg1: any, arg2: any) => {});
brings arg1
with a strange object containing only one key and that's context
; an object holding some information about - you guessed it - the context.
There is also no way for the user to specify arguments. Not through the command palette and not for keybindings.
So are those arguments only for internal stuff or are they supposed to be used by an extension developer?
To set command-line arguments in Visual Studio, right click on the project name, then go to Properties. In the Properties Pane, go to "Debugging", and in this pane is a line for "Command-line arguments." Add the values you would like to use on this line. They will be passed to the program via the argv array.
Ctrl+Shift+P > Multi command > custom command .
Note: You can review the full set of VS Code commands via the Keyboard Shortcuts editor File > Preferences > Keyboard Shortcuts (on macOS Code > Preferences > Keyboard Shortcuts).
Go to your project properties, either by right-clicking on the project and picking "Properties" or by picking Properties from the Project menu. Click on Debug, then enter your arguments into the "Script Arguments" field. Save.
In keybindings.json
you can specify arguments as such:
{
"command": "workbench.action.tasks.runTask",
"key": "alt+d",
"args": "docker"
}
To access keybindings.json
open View
> Command Palette
and type/choose Preferences: Open Keyboard Shortcuts (JSON)
. You may also want to assign a keyboard shortcut to this command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With