CommandRegistry
Class handling storage and access control for commands.
Constructor Summary
Public Constructor | ||
public |
Constructor. |
Member Summary
Private Members | ||
private |
The command aliases stored in this registry. |
|
private |
commands: StringMap<CommandObject> The commands stored in this registry. |
|
private |
groups: StringMap<CommandGroup> The command groups stored in the registry. |
Method Summary
Public Methods | ||
public |
add(configurators: ...commandConfigurator): CommandRegistry Adds the given commands to the registry. |
|
public |
applyGroupMiddleware(group: string, middleware: middlewareLayer[]): CommandRegistry Applies middleware to a command group. |
|
public |
get(identifier: string): CommandObject Gets a command from the registry. |
Private Methods | ||
private |
addCommand(command: CommandObject): CommandRegistry Adds a command to the registry. |
|
private |
alias(name: string, aliases: string[]): CommandRegistry Adds command aliases to the registry. |
|
private |
getMainName(identifier: string): string | undefined Returns the main name associated with an identifier. |
Public Constructors
Private Members
Public Methods
public add(configurators: ...commandConfigurator): CommandRegistry source
Adds the given commands to the registry.
Params:
Name | Type | Attribute | Description |
configurators | ...commandConfigurator | The command configurators. |
public applyGroupMiddleware(group: string, middleware: middlewareLayer[]): CommandRegistry source
Applies middleware to a command group.
Params:
Name | Type | Attribute | Description |
group | string | The command group to apply middleware to. |
|
middleware | middlewareLayer[] | The middleware to apply. |
Throw:
Thrown if the given group does not exist. |
|
Thrown if |
public get(identifier: string): CommandObject source
Gets a command from the registry.
Params:
Name | Type | Attribute | Description |
identifier | string | The identifier of the command in the registry, or an alias of a command. |
Return:
CommandObject (nullable: true) | The |
Throw:
Thrown if the given command name is not a string. |
Private Methods
private addCommand(command: CommandObject): CommandRegistry source
Adds a command to the registry.
Params:
Name | Type | Attribute | Description |
command | CommandObject | The command to register. |
Throw:
Thrown if a duplicate command name or alias is found. |
|
Thrown if the given command is not a |
private alias(name: string, aliases: string[]): CommandRegistry source
Adds command aliases to the registry.
Throw:
Thrown if given command name doesn't exist in the registry, or if a duplicate alias is detected. |
|
Thrown if the given name and aliases are not strings. |
private getMainName(identifier: string): string | undefined source
Returns the main name associated with an identifier.
Params:
Name | Type | Attribute | Description |
identifier | string | The identifier. |
Return:
string | undefined | The main name associated with this identifier,
or |
Throw:
Thrown if the given command identifier is not a string. |