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

Function getMaxSizeInternal

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

Source from the content-addressed store, hash-verified

882}
883
884const getMaxSizeInternal = (self: Instruction): number => {
885 switch (self._tag) {
886 case "Empty": {
887 return 0
888 }
889 case "Single": {
890 return 1
891 }
892 case "KeyValueMap": {
893 return Number.MAX_SAFE_INTEGER
894 }
895 case "Map":
896 case "WithDefault":
897 case "WithFallback": {
898 return getMaxSizeInternal(self.options as Instruction)
899 }
900 case "Both": {
901 const leftMaxSize = getMaxSizeInternal(self.left as Instruction)
902 const rightMaxSize = getMaxSizeInternal(self.right as Instruction)
903 return leftMaxSize + rightMaxSize
904 }
905 case "OrElse": {
906 const leftMin = getMaxSizeInternal(self.left as Instruction)
907 const rightMin = getMaxSizeInternal(self.right as Instruction)
908 return Math.min(leftMin, rightMin)
909 }
910 case "Variadic": {
911 const selfMaxSize = Option.getOrElse(self.max, () => Number.MAX_SAFE_INTEGER / 2)
912 const optionsMaxSize = getMaxSizeInternal(self.argumentOption as Instruction)
913 return Math.floor(selfMaxSize * optionsMaxSize)
914 }
915 }
916}
917
918const getUsageInternal = (self: Instruction): Usage.Usage => {
919 switch (self._tag) {

Callers 3

getMaxSizeFunction · 0.70
getHelpInternalFunction · 0.70
wizardInternalFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected