# bash completion for booh

_booh-backend()
{
	local cur prev

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

	case $prev in
		-@(s|d|-source|-destination))
			_filedir -d
			return 0
			;;
		-@(C|M|N|u|-config|-merge-config|-merge-config-newdirs|-use-config))
			_filedir
			return 0
			;;
		-@(t|-theme))
			COMPREPLY=( $( command ls /usr/share/booh/themes | grep "^$cur" ) )
			return 0
			;;
		-@(m|-mproc))
			COMPREPLY=( $( grep -c 'processor' /proc/cpuinfo | grep "^$cur" ) )
			return 0
			;;
	esac

	if [[ "$cur" == -* ]]; then
		COMPREPLY=( $( compgen -W '-h --help -V --version -n \
			--no-check -s --source -d --destination -t \
			--theme -C --config -k --config-skel -M \
			--merge-config -N --merge-config-newdirs -u \
			--use-config -S --sizes -m --mproc -g \
			--for-gui -v --verbose-level' -- $cur ) )
	fi
}
complete -F _booh-backend booh-backend
