_airsu_completion()
{
    local compopt current prev optlist

    current="${COMP_WORDS[$COMP_CWORD]}"
    
    prev="${COMP_WORDS[$COMP_CWORD - 1]}"

    compopt=""

    optlist="--help -h \
             --dbus -d \
             --no-dbus -n \
             --version -v"

    if [[ "${current}" =~ ^- ]]; then
        compopt=$optlist
    else
        case "${prev}" in
            --dbus|-d)
                compopt=""
                ;;

            --no-dbus|-n)
                compopt=""
                ;;
            --help|-h)
                compopt=""
                ;;

            --version|-v)
                compopt=""
                ;;

            *)
                compopt="<user_name>"
                ;;
        esac
    fi

    COMPREPLY=($(compgen -W "${compopt}" -- ${current}))

    return 0
}

complete -F _airsu_completion airsu
