MCPcopy Index your code
hub / github.com/Effect-TS/effect / getHelpInternal

Function getHelpInternal

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…