|
| 1 | +_exercism () { |
| 2 | + local cur prev |
| 3 | + |
| 4 | + COMPREPLY=() # Array variable storing the possible completions. |
| 5 | + cur=${COMP_WORDS[COMP_CWORD]} |
| 6 | + prev=${COMP_WORDS[COMP_CWORD-1]} |
| 7 | + |
| 8 | + commands="configure debug download fetch list open |
| 9 | + restore skip status submit tracks unsubmit |
| 10 | + upgrade help" |
| 11 | + tracks="csharp cpp clojure coffeescript lisp crystal |
| 12 | + dlang ecmascript elixir elm elisp erlang |
| 13 | + fsharp go haskell java javascript kotlin |
| 14 | + lfe lua mips ocaml objective-c php |
| 15 | + plsql perl5 python racket ruby rust scala |
| 16 | + scheme swift typescript bash c ceylon |
| 17 | + coldfusion delphi factor groovy haxe |
| 18 | + idris julia nim perl6 pony prolog |
| 19 | + purescript r sml vbnet powershell" |
| 20 | + config_opts="--dir --host --key --api" |
| 21 | + submit_opts="--test --comment" |
| 22 | + |
| 23 | + if [ "${#COMP_WORDS[@]}" -eq 2 ]; then |
| 24 | + COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) ) |
| 25 | + return 0 |
| 26 | + fi |
| 27 | + |
| 28 | + if [ "${#COMP_WORDS[@]}" -eq 3 ]; then |
| 29 | + case "${prev}" in |
| 30 | + configure) |
| 31 | + COMPREPLY=( $( compgen -W "${config_opts}" -- "${cur}" ) ) |
| 32 | + return 0 |
| 33 | + ;; |
| 34 | + fetch) |
| 35 | + COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) ) |
| 36 | + return 0 |
| 37 | + ;; |
| 38 | + list) |
| 39 | + COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) ) |
| 40 | + return 0 |
| 41 | + ;; |
| 42 | + open) |
| 43 | + COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) ) |
| 44 | + return 0 |
| 45 | + ;; |
| 46 | + skip) |
| 47 | + COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) ) |
| 48 | + return 0 |
| 49 | + ;; |
| 50 | + status) |
| 51 | + COMPREPLY=( $( compgen -W "${tracks}" "${cur}" ) ) |
| 52 | + return 0 |
| 53 | + ;; |
| 54 | + submit) |
| 55 | + COMPREPLY=( $( compgen -W "${submit_opts}" -- "${cur}" ) ) |
| 56 | + return 0 |
| 57 | + ;; |
| 58 | + help) |
| 59 | + COMPREPLY=( $( compgen -W "${commands}" "${cur}" ) ) |
| 60 | + return 0 |
| 61 | + ;; |
| 62 | + *) |
| 63 | + return 0 |
| 64 | + ;; |
| 65 | + esac |
| 66 | + fi |
| 67 | + |
| 68 | + return 0 |
| 69 | +} |
| 70 | + |
| 71 | +complete -F _exercism exercism |
0 commit comments