#!/bin/bash

_fwupdate()
{
	local cur=${COMP_WORDS[COMP_CWORD]}

	if [[ "$cur" == -* ]]; then
		COMPREPLY=( $( compgen -W "-a -l -d --set-debug -D --unset-debug" -- "$cur" ) )
		return 0
	fi

	case "${COMP_WORDS[COMP_CWORD-1]}" in
	-a)
		COMPREPLY=( $( compgen -W "$(fwupdate -l | cut -d\{ -f2 | cut -d\} -f1)" -- "$cur" ) )
		return 0
		;;
	esac

	case "${COMP_WORDS[COMP_CWORD-2]}" in
	-a)
		_filedir
		return 0
		;;
	esac
}

complete -F _fwupdate fwupdate
