Commands
Configuration details
This section describes new commands added to the extension, which enable enhanced interaction and automation within the development environment. These commands can be used programmatically through the API.
package.json Example
This example shows how new commands are added to package.json, enabling them for use within the extension. Each command is defined with a unique identifier and a descriptive title that appears in the command palette.
{
"contributes": {
"commands": [
{
"command": "extension.exampleCommand",
"title": "Extension: Example Command"
},
{
"command": "extension.anotherCommand",
"title": "Extension: Another Command"
}
]
}
}
And within the TypeScript code, you can use the commands like so:
const exampleCommand = extensionApi.commands.registerCommand('extension.exampleCommand', async () => {
// Implementation logic here
console.log('Executing Example Command');
});
const anotherCommand = extensionApi.commands.registerCommand('extension.anotherCommand', () => {
// Synchronous logic can be used if async processing is not required
console.log('Another Command Executed');
});
JSON Schema
{
"contributes": {
"commands": [
{
"command": "string",
"title": "string",
"category": "string (optional cateogry for prefix title)",
"enablement": "myProperty === myValue"
}
]
}
}