_BASH_SCRIPT_COMPILER_SCRIPT_NAME-completion() 
{
	local cur prev opts tag help
	COMPREPLY=()
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"
	prevPrev="${COMP_WORDS[COMP_CWORD-2]}"
	opts="mind pullAndMerge help config"
	config="print set init"

	# TODO check if this is still the most efficient way to list help options
	HELP_PATH=${BASH_SOURCE%/*}/gt-help
	help=${opts}
	#help=`ls $HELP_PATH`

	if [[ ${cur} == "help" ]] ; then
		createFromString "${help}"
		return 0
	elif [[ $COMP_CWORD -gt 1 ]]; then
		if [ "$prev" == "tag" ]; then
			# no suggestions for tags
			return 0
		elif [ "$prev" == "config" ]; then
			createFromString "$config"
		elif [ "$prevPrev" == "config" ]; then
			# no suggestions after config xyz
			return 0
		elif [ "$prev" == "--path" ] || [ "$prev" == "-p" ]; then
			createFromDirectory "$DOCKER_SERVICES_HOME"
		elif [[ $COMP_CWORD -gt 1 ]] && [ "$prev" == "-p" ]; then
			createFromDirectory "$DOCKER_SERVICES_HOME"
#		elif [[ $COMP_CWORD -gt 1 ]] && [ "$prev" != "desc" ] && [ "$prev" != "year" ]; then
#			createFromString "${twoPlus}"
		else
			createFromString "${opts}"
		fi
		return 0
	elif [[ $COMP_CWORD -eq 1 ]]; then
		createFromString "${opts}"
		return 0
	fi
}

createFromString() {
	COMPREPLY=( $(compgen -W "${1}" -- ${cur}) )
}

createFromDirectory() {
	pushd $1 >/dev/null
	COMPREPLY=( $(compgen -o plusdirs -- $cur) )
	popd >/dev/null
}

complete -F _BASH_SCRIPT_COMPILER_SCRIPT_NAME-completion BASH_SCRIPT_COMPILER_SCRIPT_NAME
