@samatawy/rules
    Preparing search index...

    Class CommandRegistry

    Registry for managing commands in the rules engine. This class allows for registering, unregistering, and retrieving commands by their unique keywords. Each command must have a unique keyword that identifies it. The registry ensures that no two commands with the same keyword can be registered at the same time. One registry should be created for each workspace, and the commands registered in the registry can then be used by the CommandHandler to execute command actions.

    Index

    Constructors

    Properties

    commands: Map<string, ICommand> = ...

    Methods

    • Add a command to the registry. Each command must have a unique keyword that identifies it. If a command with the same keyword is already registered, an error will be thrown.

      Parameters

      • command: ICommand

        the command to register.

      Returns boolean

      true if the command was successfully registered.

      an error if a command with the same keyword is already registered - or if the command is invalid.

    • Remove a command from the registry by its keyword.

      Parameters

      • keyword: string

        the keyword of the command to unregister.

      Returns boolean

      true if the command was successfully unregistered, false if no command with the given keyword was found.

    • Check if a command with the given keyword is registered in the registry.

      Parameters

      • keyword: string

        the keyword of the command to check.

      Returns boolean

      true if a command with the given keyword is registered, false otherwise.

    • Get a command from the registry by its keyword.

      Parameters

      • keyword: string

        the keyword of the command to retrieve.

      Returns ICommand | undefined

      the command with the given keyword, or undefined if no command with the given keyword is found.