# *-* mode: shell-script;-*-

if type catkin_lint &> /dev/null; then

_catkin_lint_complete()
{
	local arg="${COMP_WORDS[COMP_CWORD]}"
	local prev="${COMP_WORDS[COMP_CWORD-1]}"
	if [ "$prev" == "--pkg" -o "$prev" == "--skip-pkg" ]
	then
		COMPREPLY=( $( compgen -W "$( rospack list-names 2>/dev/null )" -- "$arg" ) )
		return 0
	fi
	if [ "$prev" == "--rosdistro" ]
	then
		COMPREPLY=( $( compgen -W "groovy hydro indigo jade kinetic lunar melodic" -- "$arg" ) )
		return 0
	fi
	if [ "$prev" == "--ignore" -o "$prev" == "--error" -o "$prev" == "--warning" -o "$prev" == "--notice" ]
	then
		COMPREPLY=( $( compgen -W "$( catkin_lint --list-check-ids )" -- "$arg" ) )
		return 0
	fi
	compopt -o filenames 2>/dev/null
	COMPREPLY=( $( compgen -W "-h -q --help --version -W0 -W1 -W2 --strict --text --explain --xml --quiet --offline --clear-cache --pkg --skip-pkg --ignore --package-path --rosdistro --resolve-env --error --warning --notice --show-suppressed" -- "$arg" ) )
	COMPREPLY+=( $( compgen -d -- "$arg" ) )
	return 0
}

complete -F _catkin_lint_complete catkin_lint

fi
