(self: Instruction)
| 1117 | |
| 1118 | /** @internal */ |
| 1119 | export 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 | |
| 1157 | const toParseableInstruction = (self: Instruction): Array<ParseableInstruction> => { |
| 1158 | switch (self._tag) { |
no test coverage detected