( self: Instruction, parentCommands: ReadonlyArray<string>, subcommands: ReadonlyArray<[string, Standard | GetUserInput]> )
| 1295 | })) |
| 1296 | |
| 1297 | const getZshSubcommandCases = ( |
| 1298 | self: Instruction, |
| 1299 | parentCommands: ReadonlyArray<string>, |
| 1300 | subcommands: ReadonlyArray<[string, Standard | GetUserInput]> |
| 1301 | ): Array<string> => { |
| 1302 | switch (self._tag) { |
| 1303 | case "Standard": |
| 1304 | case "GetUserInput": { |
| 1305 | const options = isStandard(self) |
| 1306 | ? InternalOptions.all([InternalBuiltInOptions.builtIns, self.options]) |
| 1307 | : InternalBuiltInOptions.builtIns |
| 1308 | const args = isStandard(self) ? self.args : InternalArgs.none |
| 1309 | const optionCompletions = pipe( |
| 1310 | InternalOptions.getZshCompletions(options as InternalOptions.Instruction), |
| 1311 | Arr.map((completion) => `'${completion}' \\`) |
| 1312 | ) |
| 1313 | const argCompletions = pipe( |
| 1314 | InternalArgs.getZshCompletions(args as InternalArgs.Instruction), |
| 1315 | Arr.map((completion) => `'${completion}' \\`) |
| 1316 | ) |
| 1317 | if (Arr.isEmptyReadonlyArray(parentCommands)) { |
| 1318 | return [ |
| 1319 | "_arguments \"${_arguments_options[@]}\" \\", |
| 1320 | ...indentAll(optionCompletions, 4), |
| 1321 | ...indentAll(argCompletions, 4), |
| 1322 | ` ":: :_${self.name}_commands" \\`, |
| 1323 | ` "*::: :->${self.name}" \\`, |
| 1324 | " && ret=0" |
| 1325 | ] |
| 1326 | } |
| 1327 | if (Arr.isEmptyReadonlyArray(subcommands)) { |
| 1328 | return [ |
| 1329 | `(${self.name})`, |
| 1330 | "_arguments \"${_arguments_options[@]}\" \\", |
| 1331 | ...indentAll(optionCompletions, 4), |
| 1332 | ...indentAll(argCompletions, 4), |
| 1333 | " && ret=0", |
| 1334 | ";;" |
| 1335 | ] |
| 1336 | } |
| 1337 | return [ |
| 1338 | `(${self.name})`, |
| 1339 | "_arguments \"${_arguments_options[@]}\" \\", |
| 1340 | ...indentAll(optionCompletions, 4), |
| 1341 | ...indentAll(argCompletions, 4), |
| 1342 | ` ":: :_${Arr.append(parentCommands, self.name).join("__")}_commands" \\`, |
| 1343 | ` "*::: :->${self.name}" \\`, |
| 1344 | " && ret=0" |
| 1345 | ] |
| 1346 | } |
| 1347 | case "Map": { |
| 1348 | return getZshSubcommandCases(self.command, parentCommands, subcommands) |
| 1349 | } |
| 1350 | case "Subcommands": { |
| 1351 | const nextSubcommands = getSubcommandsInternal(self) |
| 1352 | const parentNames = getNamesInternal(self.parent) |
| 1353 | const parentLines = getZshSubcommandCases( |
| 1354 | self.parent, |
no test coverage detected