# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
# ex: ts=8 sw=8 et filetype=sh
#
# bash-completion add-on for rpmlint(1)
# http://bash-completion.alioth.debian.org/

_rpmlint()
{
	local cur prev

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

	case $prev in
		-@(C|E|-@(check|extract)dir))
			_filedir -d
			return 0
			;;
		-@(f|-file))
			_filedir
			return 0
			;;
	esac


	if [[ "$cur" == -* ]]; then
		COMPREPLY=( $( compgen -W '-i --info -I -c --check \
			-a --all -C --checkdir -h --help -v --verbose \
			-E --extractdir -p --profile -V --version -n \
			--noexception -f --file' -- $cur ) )
	else
		# Installed packages completion is slow, do it only if arg
		# does not look like a path.
		if [[ "$cur" != */* ]]; then
			type _rpm_installed_packages &>/dev/null && \
				_rpm_installed_packages
		fi
		_filedir '@(rpm|spec)'
	fi
}
complete -F _rpmlint $filenames rpmlint
