Skip to content

Instantly share code, notes, and snippets.

@zyguan
Last active May 23, 2018 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zyguan/0b406011a0a2698eccadfb253d5b7075 to your computer and use it in GitHub Desktop.
Save zyguan/0b406011a0a2698eccadfb253d5b7075 to your computer and use it in GitHub Desktop.
bash-completion for liquibase
#!/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