| 624 | |
| 625 | /** @internal */ |
| 626 | export const getBashCompletions = (self: Instruction): string => { |
| 627 | switch (self._tag) { |
| 628 | case "Bool": { |
| 629 | return "\"${cur}\"" |
| 630 | } |
| 631 | case "DateTime": |
| 632 | case "Float": |
| 633 | case "Integer": |
| 634 | case "Secret": |
| 635 | case "Redacted": |
| 636 | case "Text": { |
| 637 | return "$(compgen -f \"${cur}\")" |
| 638 | } |
| 639 | case "Path": { |
| 640 | switch (self.pathType) { |
| 641 | case "file": { |
| 642 | return self.pathExists === "yes" || self.pathExists === "either" |
| 643 | ? "$(compgen -f \"${cur}\")" |
| 644 | : "" |
| 645 | } |
| 646 | case "directory": { |
| 647 | return self.pathExists === "yes" || self.pathExists === "either" |
| 648 | ? "$(compgen -d \"${cur}\")" |
| 649 | : "" |
| 650 | } |
| 651 | case "either": { |
| 652 | return self.pathExists === "yes" || self.pathExists === "either" |
| 653 | ? "$(compgen -f \"${cur}\")" |
| 654 | : "" |
| 655 | } |
| 656 | } |
| 657 | } |
| 658 | case "Choice": { |
| 659 | const choices = pipe( |
| 660 | Arr.map(self.alternatives, ([choice]) => choice), |
| 661 | Arr.join(",") |
| 662 | ) |
| 663 | return `$(compgen -W "${choices}" -- "\${cur}")` |
| 664 | } |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | /** @internal */ |
| 669 | export const getFishCompletions = (self: Instruction): Array<string> => { |