| 6 | const commandScopeSet = new Set<string>(); |
| 7 | |
| 8 | export class Command implements IPublicApiCommand { |
| 9 | [commandSymbol]: ICommand; |
| 10 | [optionsSymbol]?: ICommandOptions; |
| 11 | [pluginContextSymbol]?: IPublicModelPluginContext; |
| 12 | |
| 13 | constructor(innerCommand: ICommand, pluginContext?: IPublicModelPluginContext, options?: ICommandOptions) { |
| 14 | this[commandSymbol] = innerCommand; |
| 15 | this[optionsSymbol] = options; |
| 16 | this[pluginContextSymbol] = pluginContext; |
| 17 | const commandScope = options?.commandScope; |
| 18 | if (commandScope && commandScopeSet.has(commandScope)) { |
| 19 | throw new Error(`Command scope "${commandScope}" has been registered.`); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | registerCommand(command: IPublicTypeCommand): void { |
| 24 | this[commandSymbol].registerCommand(command, this[optionsSymbol]); |
| 25 | } |
| 26 | |
| 27 | batchExecuteCommand(commands: { name: string; args: IPublicTypeCommandHandlerArgs }[]): void { |
| 28 | this[commandSymbol].batchExecuteCommand(commands, this[pluginContextSymbol]); |
| 29 | } |
| 30 | |
| 31 | executeCommand(name: string, args: IPublicTypeCommandHandlerArgs): void { |
| 32 | this[commandSymbol].executeCommand(name, args); |
| 33 | } |
| 34 | |
| 35 | listCommands(): IPublicTypeListCommand[] { |
| 36 | return this[commandSymbol].listCommands(); |
| 37 | } |
| 38 | |
| 39 | unregisterCommand(name: string): void { |
| 40 | this[commandSymbol].unregisterCommand(name); |
| 41 | } |
| 42 | |
| 43 | onCommandError(callback: (name: string, error: Error) => void): void { |
| 44 | this[commandSymbol].onCommandError(callback); |
| 45 | } |
| 46 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…