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

Function getFishCompletions

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

Source from the content-addressed store, hash-verified

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