The simplest way is to add the following to your .bashrc.
COMPREPLY=( $(compgen -W "fooOption barOption" -- $cur) )
complete -F _cooltool cooltool
Whenever you type
cooltool f[TAB][TAB], the
_cooltool() function is invoked. It will work out what your current partial word is and then
compgen will work out which options match. These are stored in an array called
COMPREPLY which is then displayed. Look at
man complete and
man compgen for details.
For a nice tutorial check out: Writing your own Bash Completion Function