MCPcopy Create free account
hub / github.com/alibaba/lowcode-engine / Command

Class Command

packages/shell/src/api/command.ts:8–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6const commandScopeSet = new Set<string>();
7
8export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…