(self: Instruction)
| 915 | } |
| 916 | |
| 917 | const getUsageInternal = (self: Instruction): Usage.Usage => { |
| 918 | switch (self._tag) { |
| 919 | case "Empty": { |
| 920 | return InternalUsage.empty |
| 921 | } |
| 922 | case "Single": { |
| 923 | const acceptedValues = InternalPrimitive.isBool(self.primitiveType) |
| 924 | ? Option.none() |
| 925 | : Option.orElse( |
| 926 | InternalPrimitive.getChoices(self.primitiveType), |
| 927 | () => Option.some(self.placeholder) |
| 928 | ) |
| 929 | return InternalUsage.named(getNames(self), acceptedValues) |
| 930 | } |
| 931 | case "KeyValueMap": { |
| 932 | return getUsageInternal(self.argumentOption as Instruction) |
| 933 | } |
| 934 | case "Map": { |
| 935 | return getUsageInternal(self.options as Instruction) |
| 936 | } |
| 937 | case "Both": { |
| 938 | return InternalUsage.concat( |
| 939 | getUsageInternal(self.left as Instruction), |
| 940 | getUsageInternal(self.right as Instruction) |
| 941 | ) |
| 942 | } |
| 943 | case "OrElse": { |
| 944 | return InternalUsage.alternation( |
| 945 | getUsageInternal(self.left as Instruction), |
| 946 | getUsageInternal(self.right as Instruction) |
| 947 | ) |
| 948 | } |
| 949 | case "Variadic": { |
| 950 | return InternalUsage.repeated(getUsageInternal(self.argumentOption as Instruction)) |
| 951 | } |
| 952 | case "WithDefault": |
| 953 | case "WithFallback": { |
| 954 | return InternalUsage.optional(getUsageInternal(self.options as Instruction)) |
| 955 | } |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | const isBoolInternal = (self: Instruction): boolean => { |
| 960 | switch (self._tag) { |
no test coverage detected