#   bash_completion - programmable completion functions for bash 3.x
#                     (backwards compatible with bash 2.05b)
# bash command-line completion for burniso
# Author: Pablo Yanez Trujillo <yanezp@informatik.uni-freiburg.de>

_burniso()
{
	local cur
	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"

	if [[ $COMP_CWORD -eq 1 ]]; then
		COMPREPLY=($(compgen -W 'cd dvd' ${cur}))
	else
		case "${COMP_WORDS[1]}" in
			cd)
				if [ -z "${COMP_WORDS[3]}" ] && [ ! "${COMP_WORDS[2]%.iso}" != "${COMP_WORDS[2]}"  ] ; then
					COMPREPLY=($(compgen -W '$(for i in *.iso; do echo ${i##*/}; done)' ${cur}))
				elif [ -z "${COMP_WORDS[3]}" ] ; then
					COMPREPLY=($(compgen -W '-r' ${cur}))
				fi
				;;
			dvd)
				if [ ! "${COMP_WORDS[2]%.iso}" != "${COMP_WORDS[2]}"  ] ; then
					COMPREPLY=($(compgen -W '$(for i in *.iso; do echo ${i##*/}; done)' ${cur}))
				fi
				;;
		esac
	fi
}

complete -F _burniso burniso
