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

Function getZshCompletions

packages/cli/src/internal/args.ts:1073–1111  ·  view source on GitHub ↗
(
  self: Instruction,
  state: ZshCompletionState = { multiple: false, optional: false }
)

Source from the content-addressed store, hash-verified

1071}
1072
1073export const getZshCompletions = (
1074 self: Instruction,
1075 state: ZshCompletionState = { multiple: false, optional: false }
1076): Array<string> => {
1077 switch (self._tag) {
1078 case "Empty": {
1079 return Arr.empty()
1080 }
1081 case "Single": {
1082 const multiple = state.multiple ? "*" : ""
1083 const optional = state.optional ? "::" : ":"
1084 const shortDescription = getShortDescription(self)
1085 const description = shortDescription.length > 0 ? ` -- ${shortDescription}` : ""
1086 const possibleValues = InternalPrimitive.getZshCompletions(
1087 self.primitiveType as InternalPrimitive.Instruction
1088 )
1089 return possibleValues.length === 0
1090 ? Arr.empty()
1091 : Arr.of(`${multiple}${optional}${self.name}${description}${possibleValues}`)
1092 }
1093 case "Map": {
1094 return getZshCompletions(self.args as Instruction, state)
1095 }
1096 case "Both": {
1097 const left = getZshCompletions(self.left as Instruction, state)
1098 const right = getZshCompletions(self.right as Instruction, state)
1099 return Arr.appendAll(left, right)
1100 }
1101 case "Variadic": {
1102 return Option.isSome(self.max) && self.max.value > 1
1103 ? getZshCompletions(self.args as Instruction, { ...state, multiple: true })
1104 : getZshCompletions(self.args as Instruction, state)
1105 }
1106 case "WithDefault":
1107 case "WithFallbackConfig": {
1108 return getZshCompletions(self.args as Instruction, { ...state, optional: true })
1109 }
1110 }
1111}

Callers

nothing calls this directly

Calls 2

getShortDescriptionFunction · 0.70
ofMethod · 0.65

Tested by

no test coverage detected