(
self: Instruction,
isSubcommand: boolean
)
| 451 | self: Instruction |
| 452 | ): Array<[string, GetUserInput | Standard]> => { |
| 453 | const loop = ( |
| 454 | self: Instruction, |
| 455 | isSubcommand: boolean |
| 456 | ): Array<[string, GetUserInput | Standard]> => { |
| 457 | switch (self._tag) { |
| 458 | case "Standard": |
| 459 | case "GetUserInput": { |
| 460 | return Arr.of([self.name, self]) |
| 461 | } |
| 462 | case "Map": { |
| 463 | return loop(self.command, isSubcommand) |
| 464 | } |
| 465 | case "Subcommands": { |
| 466 | // Ensure that we only traverse the subcommands one level deep from the |
| 467 | // parent command |
| 468 | return isSubcommand |
| 469 | ? loop(self.parent, false) |
| 470 | : Arr.flatMap(self.children, (child) => loop(child, true)) |
| 471 | } |
| 472 | } |
| 473 | } |
| 474 | return loop(self, false) |
| 475 | } |
| 476 |
no test coverage detected