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

Function getHelpInternal

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

Source from the content-addressed store, hash-verified

721}
722
723const getHelpInternal = (self: Instruction): HelpDoc.HelpDoc => {
724 switch (self._tag) {
725 case "Empty": {
726 return InternalHelpDoc.empty
727 }
728 case "Single": {
729 return InternalHelpDoc.descriptionList(Arr.of([
730 InternalHelpDoc.getSpan(InternalUsage.getHelp(getUsageInternal(self))),
731 InternalHelpDoc.sequence(
732 InternalHelpDoc.p(InternalPrimitive.getHelp(self.primitiveType)),
733 self.description
734 )
735 ]))
736 }
737 case "KeyValueMap": {
738 // Single options always have an identifier, so we can safely `getOrThrow`
739 const identifier = Option.getOrThrow(
740 getIdentifierInternal(self.argumentOption as Instruction)
741 )
742 return InternalHelpDoc.mapDescriptionList(
743 getHelpInternal(self.argumentOption as Instruction),
744 (span, oldBlock) => {
745 const header = InternalHelpDoc.p("This setting is a property argument which:")
746 const single = `${identifier} key1=value key2=value2`
747 const multiple = `${identifier} key1=value ${identifier} key2=value2`
748 const description = InternalHelpDoc.enumeration([
749 InternalHelpDoc.p(`May be specified a single time: '${single}'`),
750 InternalHelpDoc.p(`May be specified multiple times: '${multiple}'`)
751 ])
752 const newBlock = pipe(
753 oldBlock,
754 InternalHelpDoc.sequence(header),
755 InternalHelpDoc.sequence(description)
756 )
757 return [span, newBlock]
758 }
759 )
760 }
761 case "Map": {
762 return getHelpInternal(self.options as Instruction)
763 }
764 case "Both":
765 case "OrElse": {
766 return InternalHelpDoc.sequence(
767 getHelpInternal(self.left as Instruction),
768 getHelpInternal(self.right as Instruction)
769 )
770 }
771 case "Variadic": {
772 const help = getHelpInternal(self.argumentOption as Instruction)
773 return InternalHelpDoc.mapDescriptionList(help, (oldSpan, oldBlock) => {
774 const min = getMinSizeInternal(self as Instruction)
775 const max = getMaxSizeInternal(self as Instruction)
776 const newSpan = InternalSpan.text(
777 Option.isSome(self.max) ? ` ${min} - ${max}` : min === 0 ? "..." : ` ${min}+`
778 )
779 const newBlock = InternalHelpDoc.p(
780 Option.isSome(self.max)

Callers 2

getHelpFunction · 0.70
wizardInternalFunction · 0.70

Calls 8

StringInterface · 0.85
getUsageInternalFunction · 0.70
getIdentifierInternalFunction · 0.70
pipeFunction · 0.70
getMinSizeInternalFunction · 0.70
getMaxSizeInternalFunction · 0.70
ofMethod · 0.65
textMethod · 0.45

Tested by

no test coverage detected