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

Function getFishCompletions

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

Source from the content-addressed store, hash-verified

2111
2112/** @internal */
2113export const getFishCompletions = (self: Instruction): Array<string> => {
2114 switch (self._tag) {
2115 case "Empty": {
2116 return Arr.empty()
2117 }
2118 case "Single": {
2119 const description = getShortDescription(self)
2120 const order = Order.mapInput(Order.boolean, (tuple: readonly [boolean, string]) => !tuple[0])
2121 return pipe(
2122 Arr.prepend(self.aliases, self.name),
2123 Arr.map((name) => [name.length === 1, name] as const),
2124 Arr.sort(order),
2125 Arr.flatMap(([isShort, name]) => Arr.make(isShort ? "-s" : "-l", name)),
2126 Arr.appendAll(InternalPrimitive.getFishCompletions(
2127 self.primitiveType as InternalPrimitive.Instruction
2128 )),
2129 Arr.appendAll(
2130 description.length === 0
2131 ? Arr.empty()
2132 : Arr.of(`-d '${InternalCompletion.escapeSingleQuoted(description)}'`)
2133 ),
2134 Arr.join(" "),
2135 Arr.of
2136 )
2137 }
2138 case "KeyValueMap":
2139 case "Variadic": {
2140 return getFishCompletions(self.argumentOption as Instruction)
2141 }
2142 case "Map":
2143 case "WithDefault":
2144 case "WithFallback": {
2145 return getFishCompletions(self.options as Instruction)
2146 }
2147 case "Both":
2148 case "OrElse": {
2149 return pipe(
2150 getFishCompletions(self.left as Instruction),
2151 Arr.appendAll(getFishCompletions(self.right as Instruction))
2152 )
2153 }
2154 }
2155}
2156
2157interface ZshCompletionState {
2158 readonly conflicts: ReadonlyArray<string>

Callers

nothing calls this directly

Calls 6

getShortDescriptionFunction · 0.70
pipeFunction · 0.70
mapMethod · 0.65
makeMethod · 0.65
ofMethod · 0.65
joinMethod · 0.65

Tested by

no test coverage detected