This is called bash completion. You can find many examples in /etc/bash_completion.d/ . The bash_completion function needs to be loaded to your shell before it can work. This is an example to get you started
# Bash completion must to be loaded when shell starts
# Recommended location is /etc/bash_completion.d/build_all.sh
# or added to ~/.bashrc
# Then load with . /etc/bash_completion.d/build_all.sh
# or with . ~/.bashrc
# New instances of bash will have already sourced it.
# The file name build_all.sh may be too common, and result in unwanted tab
# completion for build_all.sh from other projects.
_build_all.sh(){
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
case $COMP_CWORD in
1) COMPREPLY=( $( compgen -W '-vmware' -- "$cur" ) ) ;;
2) COMPREPLY=( $( compgen -W 'no yes' -- "${COMP_WORDS[COMP_CWORD]}" ) ) ;;
3) COMPREPLY=( $( compgen -W '-nic' -- "$cur" ) ) ;;
4) COMPREPLY=( $( compgen -W 'host_only bridged' -- "${COMP_WORDS[COMP_CWORD]}" ) ) ;;
5) COMPREPLY=( $( compgen -W '-ipaddress' -- "$cur" ) ) ;;
6) COMPREPLY=( $( compgen -W 'dhcp xx.xx.xx.xx' -- "${COMP_WORDS[COMP_CWORD]}" ) ) ;;
7) COMPREPLY=( $( compgen -W '-arch' -- "$cur" ) ) ;;
8) COMPREPLY=( $( compgen -W 'x86 ARM' -- "${COMP_WORDS[COMP_CWORD]}" ) ) ;;
esac
return 0
} &&
complete -F _build_all.sh build_all.sh