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

Function getSubcommandsInternal

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…