fixed existing completion and added conditional completion

pull/1778/head
Gurkirat Singh 2021-01-10 00:34:14 +05:30
parent e932d8371f
commit 6065d003e8
No known key found for this signature in database
GPG Key ID: CFD64E1DCB3DA835
1 changed files with 42 additions and 8 deletions

View File

@ -1,14 +1,48 @@
#!/usr/bin/bash #!/usr/bin/bash
if command -v vue > /dev/null; then if _command_exists vue; then
__vuejs_completion() { __vuejs_completion() {
local OPTS=("--version --help create add invoke inspect serve build ui init config upgrade info") local prev=$(_get_pword)
COMPREPLY=() local curr=$(_get_cword)
for _opt_ in ${OPTS[@]}; do
if [[ "$_opt_" == "$2"* ]]; then case $prev in
COMPREPLY+=("$_opt_") create)
fi 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"))
done ;;
add|invoke)
COMPREPLY=($(compgen -W "--registry -h --help" -- "$curr"))
;;
inspect)
COMPREPLY=($(compgen -W "-v --help --verbose --mode --rule --plugin --plugins --rules" -- "$curr"))
;;
serve)
COMPREPLY=($(compgen -W "-o -h --help --open -c --copy -p --port" -- "$curr"))
;;
build)
COMPREPLY=($(compgen -W "-t --target -n --name -d --dest -h --help" -- "$curr"))
;;
ui)
COMPREPLY=($(compgen -W "-H --host -p --port -D --dev --quiet --headless -h --help" -- "$curr"))
;;
init)
COMPREPLY=($(compgen -W "-c --clone --offline -h --help" -- "$curr"))
;;
config)
COMPREPLY=($(compgen -W "-g --get -s --set -d --delete -e --edit --json -h --help" -- "$curr"))
;;
outdated)
COMPREPLY=($(compgen -W "--next -h --help" -- "$curr"))
;;
upgrade)
COMPREPLY=($(compgen -W "-t --to -f --from -r --registry --all --next -h --help" -- "$curr"))
;;
migrate)
COMPREPLY=($(compgen -W "-f --from -h --help" -- "$curr"))
;;
*)
COMPREPLY=($(compgen -W "-h --help -v --version create add invoke inspect serve build ui init config outdated upgrade migrate info" -- "$curr"))
;;
esac
} }
complete -F __vuejs_completion vue complete -F __vuejs_completion vue