|
| 1 | +#compdef cogite |
| 2 | + |
| 3 | +_cogite() { |
| 4 | + if [[ ${CURRENT} -eq 2 ]]; then |
| 5 | + COMPREPLY=($(compgen -W "auth ci pr status" -- ${cur})) |
| 6 | + elif [[ ${CURRENT} -eq 3 ]]; then |
| 7 | + local cmd=${COMP_WORDS[1]} |
| 8 | + case ${cmd} in |
| 9 | + auth) |
| 10 | + COMPREPLY=($(compgen -W "add delete" -- ${cur})) |
| 11 | + ;; |
| 12 | + ci) |
| 13 | + COMPREPLY=($(compgen -W "browse" -- ${cur})) |
| 14 | + ;; |
| 15 | + pr) |
| 16 | + COMPREPLY=($(compgen -W "add browse draft merge ready rebase reqreview" -- ${cur})) |
| 17 | + ;; |
| 18 | + status) |
| 19 | + COMPREPLY=($(compgen -W "--poll" -- ${cur})) |
| 20 | + ;; |
| 21 | + esac |
| 22 | + elif [[ ${CURRENT} -gt 3 ]]; then |
| 23 | + local cmd="${COMP_WORDS[1]} ${COMP_WORDS[2]}" |
| 24 | + case ${cmd} in |
| 25 | + "auth add") |
| 26 | + COMPREPLY=($(compgen -W "--help" -- ${cur})) |
| 27 | + ;; |
| 28 | + "auth delete") |
| 29 | + COMPREPLY=($(compgen -W "--help" -- ${cur})) |
| 30 | + ;; |
| 31 | + "ci browse") |
| 32 | + COMPREPLY=($(compgen -W "--help" -- ${cur})) |
| 33 | + ;; |
| 34 | + "pr add") |
| 35 | + COMPREPLY=($(compgen -W "--help --base --draft" -- ${cur})) |
| 36 | + # FIXME (dbaty, 2021-12-04) : I would like to use `_arguments` |
| 37 | + # to have more detailed auto-completion, with this: |
| 38 | + # _arguments \ |
| 39 | + # '--base[branch where changes should be applied]' \ |
| 40 | + # '--draft[mark as a draft pull request]' |
| 41 | + # ... but I get the following error: |
| 42 | + # _arguments:34: bad output format specification |
| 43 | + # _arguments:366: bad math expression: operator expected at `descrs' |
| 44 | + ;; |
| 45 | + "pr browse") |
| 46 | + COMPREPLY=($(compgen -W "--help --browse" -- ${cur})) |
| 47 | + ;; |
| 48 | + "pr draft") |
| 49 | + COMPREPLY=($(compgen -W "--help --base" -- ${cur})) |
| 50 | + ;; |
| 51 | + "pr merge") |
| 52 | + COMPREPLY=($(compgen -W "--help" -- ${cur})) |
| 53 | + ;; |
| 54 | + "pr ready") |
| 55 | + COMPREPLY=($(compgen -W "--help" -- ${cur})) |
| 56 | + ;; |
| 57 | + "pr rebase") |
| 58 | + COMPREPLY=($(compgen -W "--help" -- ${cur})) |
| 59 | + ;; |
| 60 | + "pr reqreview") |
| 61 | + COMPREPLY=($(compgen -W "--help" -- ${cur})) |
| 62 | + ;; |
| 63 | + esac |
| 64 | + fi |
| 65 | +} |
| 66 | + |
| 67 | +complete -F _cogite cogite |
0 commit comments