Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace commands

Commands are functions that are implemented and registered by extensions. Extensions can invoke any command (including commands registered by other extensions). The extension can also define contributions (in package.json), such as actions and menu items, that invoke a command.

Index

Functions

executeCommand

  • executeCommand<T>(command: string, ...args: any[]): Promise<T>
  • Executes the command with the given command identifier.

    throws

    If no command exists with the given command identifier, an error is thrown.

    Type parameters

    • T

      The result type of the command.

    Parameters

    • command: string

      Identifier of the command to execute.

    • Rest ...args: any[]

    Returns Promise<T>

    A {@link Promise} that resolves to the result of the given command.

registerCommand

  • registerCommand(command: string, callback: (...args: any[]) => any): Unsubscribable
  • Registers a command that can be invoked by an action or menu item, or directly (with commands.executeCommand).

    throws

    Registering a command with an existing command identifier throws an error.

    Parameters

    • command: string

      A unique identifier for the command.

    • callback: (...args: any[]) => any

      A command function. If it returns a {@link Promise}, execution waits until it is resolved.

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns Unsubscribable

    Unsubscribable to unregister this command.

Generated using TypeDoc