MCPcopy Create free account
hub / github.com/facebook/memlab / getFullOptionsFromPrerequisiteChain

Function getFullOptionsFromPrerequisiteChain

packages/cli/src/BaseCommand.ts:54–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

52 }
53
54 getFullOptionsFromPrerequisiteChain(): BaseOption[] {
55 const self = this as unknown as BaseCommand;
56 const uniqueOptions = new Map();
57 const visitedCommands = new Set();
58 const queue: BaseCommand[] = [self];
59 const excludedOptions = new Set(
60 self.getExcludedOptions().map(option => option.getOptionName()),
61 );
62 while (queue.length > 0) {
63 const cur = queue.shift() as BaseCommand;
64 const options = cur.getOptions();
65 for (const option of options) {
66 const optionName = option.getOptionName();
67 if (excludedOptions.has(optionName)) {
68 continue;
69 }
70 if (!uniqueOptions.has(optionName)) {
71 uniqueOptions.set(optionName, option);
72 }
73 }
74 visitedCommands.add(cur.getCommandName());
75 for (const prereq of cur.getPrerequisites()) {
76 if (!visitedCommands.has(prereq.getCommandName())) {
77 queue.push(prereq);
78 }
79 }
80 }
81 return [...uniqueOptions.values()];
82 }
83}
84
85export default class BaseCommand extends Command {

Callers

nothing calls this directly

Calls 9

valuesMethod · 0.80
getExcludedOptionsMethod · 0.45
getOptionNameMethod · 0.45
getOptionsMethod · 0.45
hasMethod · 0.45
setMethod · 0.45
addMethod · 0.45
getCommandNameMethod · 0.45
getPrerequisitesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…