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

Function getSubcommandsInternal

packages/cli/src/internal/commandDescriptor.ts:450–475  ·  view source on GitHub ↗
(
  self: Instruction
)

Source from the content-addressed store, hash-verified

448}
449
450const getSubcommandsInternal = (
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
477const getUsageInternal = (self: Instruction): Usage.Usage => {
478 switch (self._tag) {

Callers 4

getSubcommandsFunction · 0.85
parseInternalFunction · 0.85
loopFunction · 0.85
getZshSubcommandCasesFunction · 0.85

Calls 1

loopFunction · 0.70

Tested by

no test coverage detected