Last active
May 23, 2018 14:08
-
-
Save zyguan/0b406011a0a2698eccadfb253d5b7075 to your computer and use it in GitHub Desktop.
bash-completion for liquibase
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
#!/bin/bash | |
_liquibase() | |
{ | |
local cur=${COMP_WORDS[COMP_CWORD]} | |
local prv=${COMP_WORDS[COMP_CWORD-1]} | |
local opts cmds | |
opts="$(liquibase --help 2>&1 | grep -e '^ --[a-z][a-zA-Z]*' -o)" | |
cmds="$(liquibase --help 2>&1 | grep -e '^ [a-zA-Z]\+' -o)" | |
if [[ $cmds =~ (^|[[:space:]])$prv($|[[:space:]]) ]]; then | |
case "$prv" in | |
status|unexpectedChangeSets) | |
COMPREPLY=( $(compgen -W "--verbose" -- "$cur") ) | |
;; | |
esac | |
else | |
case "$cur" in | |
-*) | |
COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) | |
;; | |
*) | |
COMPREPLY=( $(compgen -W "$cmds" -- "$cur") ) | |
;; | |
esac | |
fi | |
return 0 | |
} | |
complete -o default -F _liquibase liquibase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment