MCPcopy
hub / github.com/Effect-TS/effect / getNames

Function getNames

packages/cli/src/internal/options.ts:1119–1155  ·  view source on GitHub ↗
(self: Instruction)

Source from the content-addressed store, hash-verified

1117
1118/** @internal */
1119export const getNames = (self: Instruction): Array<string> => {
1120 const loop = (self: Instruction): ReadonlyArray<string> => {
1121 switch (self._tag) {
1122 case "Empty": {
1123 return Arr.empty()
1124 }
1125 case "Single": {
1126 return Arr.prepend(self.aliases, self.name)
1127 }
1128 case "KeyValueMap":
1129 case "Variadic": {
1130 return loop(self.argumentOption as Instruction)
1131 }
1132 case "Map":
1133 case "WithDefault":
1134 case "WithFallback": {
1135 return loop(self.options as Instruction)
1136 }
1137 case "Both":
1138 case "OrElse": {
1139 const left = loop(self.left as Instruction)
1140 const right = loop(self.right as Instruction)
1141 return Arr.appendAll(left, right)
1142 }
1143 }
1144 }
1145 const order = Order.mapInput(
1146 Order.boolean,
1147 (tuple: [boolean, string]) => !tuple[0]
1148 )
1149 return pipe(
1150 loop(self),
1151 Arr.map((str) => makeFullName(str)),
1152 Arr.sort(order),
1153 Arr.map((tuple) => tuple[1])
1154 )
1155}
1156
1157const toParseableInstruction = (self: Instruction): Array<ParseableInstruction> => {
1158 switch (self._tag) {

Callers 6

getUsageInternalFunction · 0.70
parseInternalFunction · 0.70
wizardInternalFunction · 0.70
parseCommandLineFunction · 0.70
getBashCompletionsFunction · 0.70
getZshCompletionsFunction · 0.70

Calls 4

makeFullNameFunction · 0.85
pipeFunction · 0.70
loopFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected