# Debian nasup(8) completion.

have nasup &&
_nasup() 
{
	dashify()
	{
		local i

		for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
			if [ ${#COMPREPLY[i]} -le 2 ]; then
				COMPREPLY[i]=-${COMPREPLY[i]}
			else
				COMPREPLY[i]=--${COMPREPLY[i]}
			fi
		done
	}

	local cur cur_nodash prev

	COMPREPLY=()
	cur=${COMP_WORDS[COMP_CWORD]}
	cur_nodash=${cur#-}
	prev=${COMP_WORDS[COMP_CWORD-1][COMP_CWORD-2]}

	if [ $COMP_CWORD = 1 ]; then
		# first parameter on line
		case "$cur" in
		-h*)
			COMPREPLY=( $( compgen -W 'help' \
				       $cur_nodash ) )
			dashify
			return 0
			;;
		-r*)
			COMPREPLY=( $( compgen -W 'report' \
				       $cur_nodash ) )
			dashify
			return 0
			;;
		-s*)
			COMPREPLY=( $( compgen -W 'scan' \
				       $cur_nodash ) )
			dashify
			return 0
			;;
		-v*)
			COMPREPLY=( $( compgen -W 'version' \
				       $cur_nodash ) )
			dashify
			return 0
			;;
		--*)
			COMPREPLY=( $( compgen -W 'help report scan version' ${cur_nodash#-} ) )
			dashify;
			return 0
			;;
		*)
			COMPREPLY=( $( compgen -W 'h r s v' \
				       $cur_nodash ) )
			dashify
			return 0
			;;
		esac
	fi
	if [ $COMP_CWORD = 2 ]; then
		case "${COMP_WORDS[1]}" in
		--h*)
			# complete on list of relevant options
			COMPREPLY=( $( compgen -W 'help scan version nfs report' ${cur_nodash#-} ) )
			#dashify;
			return 0
			;;
		-h)
			# complete on list of relevant options
			COMPREPLY=( $( compgen -W 'help scan version nfs report' ${cur_nodash#-} ) )
			#dashify;
			return 0
			;;
		--n*)
			# scan long
			COMPREPLY=( $( compgen -W 'add remove' ${cur_nodash#-} ) )
			dashify
			return 0
			;;
		esac
	fi
}
complete -F _nasup nasup


