From 035fc920adc46ee524652bf3e501c1ad96c8f6e4 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Fri, 12 Mar 2021 13:59:14 +0530 Subject: [PATCH] completion (improvement): remove if statement --- completion/available/ngrok.completion.bash | 78 +++++++++++----------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/completion/available/ngrok.completion.bash b/completion/available/ngrok.completion.bash index cc08b9aa..64789b72 100644 --- a/completion/available/ngrok.completion.bash +++ b/completion/available/ngrok.completion.bash @@ -1,45 +1,43 @@ # shellcheck shell=bash -if _binary_exists ngrok; then - __ngrok_completion() { - local prev=$(_get_pword) - local curr=$(_get_cword) +__ngrok_completion() { + local prev=$(_get_pword) + local curr=$(_get_cword) - local BASE_NO_CONF="--log --log-format --log-level" - local BASE="--config $BASE_NO_CONF" - local DEFAULT="$BASE --authtoken --region" + local BASE_NO_CONF="--log --log-format --log-level" + local BASE="--config $BASE_NO_CONF" + local DEFAULT="$BASE --authtoken --region" - case $prev in - authtoken) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$BASE" -- "$curr")) - ;; - http) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$DEFAULT --auth --bind-tls --host-header --hostname --inspect --subdomain" -- "$curr")) - ;; - start) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$DEFAULT --all --none" -- "$curr")) - ;; - tcp) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$DEFAULT --remote-addr" -- "$curr")) - ;; - tls) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$DEFAULT --client-cas --crt --hostname --key --subdomain" -- "$curr")) - ;; - update) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "$BASE_NO_CONF --channel" -- "$curr")) - ;; - *) - # shellcheck disable=SC2207 - COMPREPLY=($(compgen -W "authtoken credits http start tcp tls update version help" -- "$curr")) - ;; - esac - } + case $prev in + authtoken) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$BASE" -- "$curr")) + ;; + http) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$DEFAULT --auth --bind-tls --host-header --hostname --inspect --subdomain" -- "$curr")) + ;; + start) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$DEFAULT --all --none" -- "$curr")) + ;; + tcp) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$DEFAULT --remote-addr" -- "$curr")) + ;; + tls) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$DEFAULT --client-cas --crt --hostname --key --subdomain" -- "$curr")) + ;; + update) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "$BASE_NO_CONF --channel" -- "$curr")) + ;; + *) + # shellcheck disable=SC2207 + COMPREPLY=($(compgen -W "authtoken credits http start tcp tls update version help" -- "$curr")) + ;; + esac +} - complete -F __ngrok_completion ngrok -fi +complete -F __ngrok_completion ngrok