refactor(minikube): standardize completion generation

Closes #10763
This commit is contained in:
Carlo Sala 2024-01-02 21:01:17 +01:00
parent fa770f9678
commit a9b6af5b23
No known key found for this signature in database
GPG Key ID: DA6FB450C1A4FE9A

View File

@ -1,13 +1,13 @@
# Autocompletion for Minikube.
#
if (( $+commands[minikube] )); then
__MINIKUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minikube_completion"
if [[ ! -f $__MINIKUBE_COMPLETION_FILE ]]; then
minikube completion zsh >! $__MINIKUBE_COMPLETION_FILE
fi
[[ -f $__MINIKUBE_COMPLETION_FILE ]] && source $__MINIKUBE_COMPLETION_FILE
unset __MINIKUBE_COMPLETION_FILE
if (( ! $+commands[minikube] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `minikube`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_minikube" ]]; then
typeset -g -A _comps
autoload -Uz _minikube
_comps[minikube]=_minikube
fi
minikube completion zsh >| "$ZSH_CACHE_DIR/completions/_minikube" &|