improve (completions): simplify and fix enable logic

pull/2118/head
Gurkirat Singh 2022-03-09 00:12:03 +05:30
parent 3a778072db
commit 150d054fe6
No known key found for this signature in database
GPG Key ID: 5D829219EF259AA5
1 changed files with 44 additions and 57 deletions

View File

@ -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
case $cmd 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"))
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)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "--registry -h --help" -- "$curr"))
COMPREPLY=(--registry -h --help)
;;
inspect)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-v --help --verbose --mode --rule --plugin --plugins --rules" -- "$curr"))
COMPREPLY=(-v -h --help --verbose --mode --rule --plugin --plugins --rules)
;;
serve)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-o -h --help --open -c --copy -p --port" -- "$curr"))
COMPREPLY=(-o -h --help --open -c --copy -p --port)
;;
build)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-t --target -n --name -d --dest -h --help" -- "$curr"))
COMPREPLY=(-t --target -n --name -d --dest -h --help)
;;
ui)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-H --host -p --port -D --dev --quiet --headless -h --help" -- "$curr"))
COMPREPLY=(-H --host -p --port -D --dev --quiet --headless -h --help)
;;
init)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-c --clone --offline -h --help" -- "$curr"))
COMPREPLY=(-c --clone --offline -h --help)
;;
config)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-g --get -s --set -d --delete -e --edit --json -h --help" -- "$curr"))
COMPREPLY=(-g --get -s --set -d --delete -e --edit --json -h --help)
;;
outdated)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "--next -h --help" -- "$curr"))
COMPREPLY=(--next -h --help)
;;
upgrade)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-t --to -f --from -r --registry --all --next -h --help" -- "$curr"))
COMPREPLY=(-t --to -f --from -r --registry --all --next -h --help)
;;
migrate)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-f --from -h --help" -- "$curr"))
COMPREPLY=(-f --from -h --help)
;;
*)
# shellcheck disable=SC2207
COMPREPLY=($(compgen -W "-h --help -v --version create add invoke inspect serve build ui init config outdated upgrade migrate info" -- "$curr"))
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