_pac_commands()
{
	pac --help | sed -e '1,/^Options:/d' -e '/^See /Q' -e 's/^[\t]\+\(--.\+\)\(=.\+\)* : .*/\1/g' -e 's/^\(.\+\)=.\+/\1=/g' | uniq
}

have pac &&
_pac()
{
	cur=${COMP_WORDS[COMP_CWORD]}
	prev=${COMP_WORDS[COMP_CWORD-1]}
	COMPREPLY=()
	if [[ "$cur" == "" ]] ; then
		options=$(_pac_commands)
	elif [[ "$cur" == -* ]] ; then
		options=$(_pac_commands)
	fi

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

[ "$have" ] && complete -F _pac pac

