Created
November 14, 2021 13:09
-
-
Save judaew/76b3df37ca11c079506105ffc6fe1440 to your computer and use it in GitHub Desktop.
Bash completion for go2port
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_go2port () { | |
local cur | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
local -a opts=( | |
-d | |
-h | |
-v | |
--debug | |
--help | |
--version | |
) | |
local cmds="get update help" | |
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]]; then | |
COMPREPLY=( $(compgen -W "${opts[*]} ${cmds}" -- "${cur}") ) | |
return 0 | |
fi | |
case "${prev}" in | |
-d|--debug) | |
COMPREPLY=( $(compgen -W "${cmds}" -- "${cur}") ) | |
return 0 | |
;; | |
-v|--version) | |
COMPREPLY=() | |
return 0 | |
;; | |
-h|--help) | |
COMPREPLY=() | |
return 0 | |
;; | |
*) | |
COMPREPLY=() | |
;; | |
esac | |
} | |
complete -F _go2port go2port |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment