# Debian code-cleanup(8) completion.

have code-cleanup &&
_code-cleanup()
{
	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
		-*)
			COMPREPLY=$( compgen -W 'help' "${cur_nodash}" )
			dashify
			return 0
			;;
		--*)
			COMPREPLY=( $( compgen -W 'help' ${cur_nodash#-} ) )
			dashify;
			return 0
			;;
		*)
			COMPREPLY=( $( compgen -f $cur ) )
			# complete on deb files
			return 0
			;;
		esac
	fi
}
complete -F _code-cleanup code-cleanup

# ex: filetype=sh
