import * as vscode from 'vscode'; function openTerminal() { vscode.commands.executeCommand('workbench.action.terminal.new'); } export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.commands.registerCommand('myExtension.openTerminal', openTerminal)); }
import * as vscode from 'vscode'; function promptUser() { vscode.window.showInputBox().then((input) => { vscode.window.showInformationMessage(`You entered: ${input}`); }); } export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.commands.registerCommand('myExtension.promptUser', promptUser)); }Here, we define a function that shows an input box dialog and then displays the user's input in a notification. We then register the command with the CommandsRegistry using the `context.subscriptions.push()` method. Overall, TypeScript vs.platform.commands.common.commands CommandsRegistry is a useful package library for registering and handling commands in VS Code extensions. It provides an easy-to-use API for creating command workflows and integrating with other VS Code APIs.