MCPcopy Create free account
hub / github.com/chhoumann/quickadd / addCommandForChoice

Method addCommandForChoice

src/main.ts:490–512  ·  view source on GitHub ↗
(choice: IChoice)

Source from the content-addressed store, hash-verified

488 }
489
490 public addCommandForChoice(choice: IChoice) {
491 if (choice.type === "Multi") {
492 this.addCommandsForChoices((<IMultiChoice>choice).choices);
493 }
494
495 if (choice.command) {
496 const choiceId = choice.id;
497
498 this.addCommand({
499 id: `choice:${choiceId}`,
500 name: choice.name,
501 icon: resolveChoiceIcon(choice),
502 callback: async () => {
503 try {
504 const current = this.getChoiceById(choiceId);
505 await new ChoiceExecutor(this.app, this).execute(current);
506 } catch (err) {
507 reportError(err, `Error executing choice ${choiceId}`);
508 }
509 },
510 });
511 }
512 }
513
514 public getChoiceById(choiceId: string): IChoice {
515 const choice = this.getChoice("id", choiceId);

Callers 3

addCommandsForChoicesMethod · 0.95
enableCommandMethod · 0.80
updateCommandMethod · 0.80

Calls 6

addCommandsForChoicesMethod · 0.95
getChoiceByIdMethod · 0.95
resolveChoiceIconFunction · 0.90
reportErrorFunction · 0.90
executeMethod · 0.65
addCommandMethod · 0.45

Tested by

no test coverage detected