|
| 1 | +_just() { |
| 2 | + local i cur prev opts cmds |
| 3 | + COMPREPLY=() |
| 4 | + cur="${COMP_WORDS[COMP_CWORD]}" |
| 5 | + prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 6 | + cmd="" |
| 7 | + opts="" |
| 8 | + |
| 9 | + for i in ${COMP_WORDS[@]} |
| 10 | + do |
| 11 | + case "${i}" in |
| 12 | + "$1") |
| 13 | + cmd="just" |
| 14 | + ;; |
| 15 | + |
| 16 | + *) |
| 17 | + ;; |
| 18 | + esac |
| 19 | + done |
| 20 | + |
| 21 | + case "${cmd}" in |
| 22 | + just) |
| 23 | + opts=" -n -q -u -v -e -l -h -V -f -d -c -s --check --yes --dry-run --highlight --no-dotenv --no-highlight --quiet --shell-command --clear-shell-args --unsorted --unstable --verbose --changelog --choose --dump --edit --evaluate --fmt --init --list --summary --variables --help --version --chooser --color --command-color --dump-format --list-heading --list-prefix --justfile --set --shell --shell-arg --working-directory --command --completions --show --dotenv-filename --dotenv-path <ARGUMENTS>... " |
| 24 | + if [[ ${cur} == -* ]] ; then |
| 25 | + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) |
| 26 | + return 0 |
| 27 | + elif [[ ${COMP_CWORD} -eq 1 ]]; then |
| 28 | + local recipes=$(just --summary 2> /dev/null) |
| 29 | + |
| 30 | + if echo "${cur}" | \grep -qF '/'; then |
| 31 | + local path_prefix=$(echo "${cur}" | sed 's/[/][^/]*$/\//') |
| 32 | + local recipes=$(just --summary 2> /dev/null -- "${path_prefix}") |
| 33 | + local recipes=$(printf "${path_prefix}%s\t" $recipes) |
| 34 | + fi |
| 35 | + |
| 36 | + if [[ $? -eq 0 ]]; then |
| 37 | + COMPREPLY=( $(compgen -W "${recipes}" -- "${cur}") ) |
| 38 | + return 0 |
| 39 | + fi |
| 40 | + fi |
| 41 | + case "${prev}" in |
| 42 | + |
| 43 | + --chooser) |
| 44 | + COMPREPLY=($(compgen -f "${cur}")) |
| 45 | + return 0 |
| 46 | + ;; |
| 47 | + --color) |
| 48 | + COMPREPLY=($(compgen -W "auto always never" -- "${cur}")) |
| 49 | + return 0 |
| 50 | + ;; |
| 51 | + --command-color) |
| 52 | + COMPREPLY=($(compgen -W "black blue cyan green purple red yellow" -- "${cur}")) |
| 53 | + return 0 |
| 54 | + ;; |
| 55 | + --dump-format) |
| 56 | + COMPREPLY=($(compgen -W "just json" -- "${cur}")) |
| 57 | + return 0 |
| 58 | + ;; |
| 59 | + --list-heading) |
| 60 | + COMPREPLY=($(compgen -f "${cur}")) |
| 61 | + return 0 |
| 62 | + ;; |
| 63 | + --list-prefix) |
| 64 | + COMPREPLY=($(compgen -f "${cur}")) |
| 65 | + return 0 |
| 66 | + ;; |
| 67 | + --justfile) |
| 68 | + COMPREPLY=($(compgen -f "${cur}")) |
| 69 | + return 0 |
| 70 | + ;; |
| 71 | + -f) |
| 72 | + COMPREPLY=($(compgen -f "${cur}")) |
| 73 | + return 0 |
| 74 | + ;; |
| 75 | + --set) |
| 76 | + COMPREPLY=($(compgen -f "${cur}")) |
| 77 | + return 0 |
| 78 | + ;; |
| 79 | + --shell) |
| 80 | + COMPREPLY=($(compgen -f "${cur}")) |
| 81 | + return 0 |
| 82 | + ;; |
| 83 | + --shell-arg) |
| 84 | + COMPREPLY=($(compgen -f "${cur}")) |
| 85 | + return 0 |
| 86 | + ;; |
| 87 | + --working-directory) |
| 88 | + COMPREPLY=($(compgen -f "${cur}")) |
| 89 | + return 0 |
| 90 | + ;; |
| 91 | + -d) |
| 92 | + COMPREPLY=($(compgen -f "${cur}")) |
| 93 | + return 0 |
| 94 | + ;; |
| 95 | + --command) |
| 96 | + COMPREPLY=($(compgen -f "${cur}")) |
| 97 | + return 0 |
| 98 | + ;; |
| 99 | + -c) |
| 100 | + COMPREPLY=($(compgen -f "${cur}")) |
| 101 | + return 0 |
| 102 | + ;; |
| 103 | + --completions) |
| 104 | + COMPREPLY=($(compgen -W "zsh bash fish powershell elvish" -- "${cur}")) |
| 105 | + return 0 |
| 106 | + ;; |
| 107 | + --show) |
| 108 | + COMPREPLY=($(compgen -f "${cur}")) |
| 109 | + return 0 |
| 110 | + ;; |
| 111 | + -s) |
| 112 | + COMPREPLY=($(compgen -f "${cur}")) |
| 113 | + return 0 |
| 114 | + ;; |
| 115 | + --dotenv-filename) |
| 116 | + COMPREPLY=($(compgen -f "${cur}")) |
| 117 | + return 0 |
| 118 | + ;; |
| 119 | + --dotenv-path) |
| 120 | + COMPREPLY=($(compgen -f "${cur}")) |
| 121 | + return 0 |
| 122 | + ;; |
| 123 | + *) |
| 124 | + COMPREPLY=() |
| 125 | + ;; |
| 126 | + esac |
| 127 | + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) |
| 128 | + return 0 |
| 129 | + ;; |
| 130 | + |
| 131 | + esac |
| 132 | +} |
| 133 | + |
| 134 | +complete -F _just -o bashdefault -o default just |
0 commit comments