MCPcopy Create free account
hub / github.com/Effect-TS/effect / getNames

Function getNames

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

Source from the content-addressed store, hash-verified

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