diff --git a/completion/available/vuejs.completion.bash b/completion/available/vuejs.completion.bash index 751658f0..10019418 100644 --- a/completion/available/vuejs.completion.bash +++ b/completion/available/vuejs.completion.bash @@ -1,61 +1,48 @@ # shellcheck shell=bash -__vuejs_completion() { - # shellcheck disable=SC2155 - local prev=$(_get_pword) - # shellcheck disable=SC2155 - local curr=$(_get_cword) +if _command_exists vue; then + __vuejs_completion() { + local cmd=${COMP_WORDS[1]} - case $prev in - create) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-p -d -i -m -r -g -n -f -c -x -b -h --help --preset --default --inilinePreset --packageManager --registry --git --no-git --force --merge --clone --proxy --bare --skipGetStarted" -- "$curr")) - ;; - add | invoke) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "--registry -h --help" -- "$curr")) - ;; - inspect) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-v --help --verbose --mode --rule --plugin --plugins --rules" -- "$curr")) - ;; - serve) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-o -h --help --open -c --copy -p --port" -- "$curr")) - ;; - build) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-t --target -n --name -d --dest -h --help" -- "$curr")) - ;; - ui) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-H --host -p --port -D --dev --quiet --headless -h --help" -- "$curr")) - ;; - init) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-c --clone --offline -h --help" -- "$curr")) - ;; - config) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-g --get -s --set -d --delete -e --edit --json -h --help" -- "$curr")) - ;; - outdated) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "--next -h --help" -- "$curr")) - ;; - upgrade) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-t --to -f --from -r --registry --all --next -h --help" -- "$curr")) - ;; - migrate) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-f --from -h --help" -- "$curr")) - ;; - *) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "-h --help -v --version create add invoke inspect serve build ui init config outdated upgrade migrate info" -- "$curr")) - ;; - esac -} + case $cmd in + create) + COMPREPLY=(-p -d -i -m -r -g -n -f -c -x -b -h --help --preset --default --inilinePreset --packageManager --registry --git --no-git --force --merge --clone --proxy --bare --skipGetStarted) + ;; + add | invoke) + COMPREPLY=(--registry -h --help) + ;; + inspect) + COMPREPLY=(-v -h --help --verbose --mode --rule --plugin --plugins --rules) + ;; + serve) + COMPREPLY=(-o -h --help --open -c --copy -p --port) + ;; + build) + COMPREPLY=(-t --target -n --name -d --dest -h --help) + ;; + ui) + COMPREPLY=(-H --host -p --port -D --dev --quiet --headless -h --help) + ;; + init) + COMPREPLY=(-c --clone --offline -h --help) + ;; + config) + COMPREPLY=(-g --get -s --set -d --delete -e --edit --json -h --help) + ;; + outdated) + COMPREPLY=(--next -h --help) + ;; + upgrade) + COMPREPLY=(-t --to -f --from -r --registry --all --next -h --help) + ;; + migrate) + COMPREPLY=(-f --from -h --help) + ;; + *) + COMPREPLY=(-h --help -V --version create add invoke inspect serve build ui init config outdated upgrade migrate info) + ;; + esac + } -complete -F __vuejs_completion vue + complete -F __vuejs_completion -X '!&*' vue +fi