completion (improvement): remove if statement

pull/1850/head
Gurkirat Singh 2021-03-12 13:59:14 +05:30 committed by Noah Gorny
parent ab011cd9ba
commit 035fc920ad
1 changed files with 38 additions and 40 deletions

View File

@ -1,45 +1,43 @@
# shellcheck shell=bash # shellcheck shell=bash
if _binary_exists ngrok; then __ngrok_completion() {
__ngrok_completion() { local prev=$(_get_pword)
local prev=$(_get_pword) local curr=$(_get_cword)
local curr=$(_get_cword)
local BASE_NO_CONF="--log --log-format --log-level" local BASE_NO_CONF="--log --log-format --log-level"
local BASE="--config $BASE_NO_CONF" local BASE="--config $BASE_NO_CONF"
local DEFAULT="$BASE --authtoken --region" local DEFAULT="$BASE --authtoken --region"
case $prev in case $prev in
authtoken) authtoken)
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$BASE" -- "$curr")) COMPREPLY=($(compgen -W "$BASE" -- "$curr"))
;; ;;
http) http)
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$DEFAULT --auth --bind-tls --host-header --hostname --inspect --subdomain" -- "$curr")) COMPREPLY=($(compgen -W "$DEFAULT --auth --bind-tls --host-header --hostname --inspect --subdomain" -- "$curr"))
;; ;;
start) start)
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$DEFAULT --all --none" -- "$curr")) COMPREPLY=($(compgen -W "$DEFAULT --all --none" -- "$curr"))
;; ;;
tcp) tcp)
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$DEFAULT --remote-addr" -- "$curr")) COMPREPLY=($(compgen -W "$DEFAULT --remote-addr" -- "$curr"))
;; ;;
tls) tls)
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$DEFAULT --client-cas --crt --hostname --key --subdomain" -- "$curr")) COMPREPLY=($(compgen -W "$DEFAULT --client-cas --crt --hostname --key --subdomain" -- "$curr"))
;; ;;
update) update)
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "$BASE_NO_CONF --channel" -- "$curr")) COMPREPLY=($(compgen -W "$BASE_NO_CONF --channel" -- "$curr"))
;; ;;
*) *)
# shellcheck disable=SC2207 # shellcheck disable=SC2207
COMPREPLY=($(compgen -W "authtoken credits http start tcp tls update version help" -- "$curr")) COMPREPLY=($(compgen -W "authtoken credits http start tcp tls update version help" -- "$curr"))
;; ;;
esac esac
} }
complete -F __ngrok_completion ngrok complete -F __ngrok_completion ngrok
fi