Skip to content

Instantly share code, notes, and snippets.

@jwgstr
Created July 14, 2011 21:04
Show Gist options
  • Save jwgstr/1083437 to your computer and use it in GitHub Desktop.
Save jwgstr/1083437 to your computer and use it in GitHub Desktop.
Stratus Bash Completion
_stratus()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="exec list list-storage create-formatted-snapshot"
if [[ ${prev} == stratus ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
opts=`find ~/.stratus -name "*.cfg" -exec grep "\[.*\]" {} \; | grep -v "DEFAULT" | tr -d "[" | tr -d "]"`
if [[ ${prev} == exec ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
opts="launch-master launch-slaves terminate-dead-nodes details launch-cluster terminate-cluster login proxy list-storage create-storage delete-storage"
prevprev="${COMP_WORDS[COMP_CWORD-2]}"
if [[ ${prevprev} == exec ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _stratus stratus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment