_wyrm() {
    local i cur prev opts cmd
    COMPREPLY=()
    if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
        cur="$2"
    else
        cur="${COMP_WORDS[COMP_CWORD]}"
    fi
    prev="$3"
    cmd=""
    opts=""

    for i in "${COMP_WORDS[@]:0:COMP_CWORD}"
    do
        case "${cmd},${i}" in
            ",$1")
                cmd="wyrm"
                ;;
            wyrm,help)
                cmd="wyrm__subcmd__help"
                ;;
            wyrm,netcheck)
                cmd="wyrm__subcmd__netcheck"
                ;;
            wyrm,receive)
                cmd="wyrm__subcmd__receive"
                ;;
            wyrm,send)
                cmd="wyrm__subcmd__send"
                ;;
            wyrm,shim)
                cmd="wyrm__subcmd__shim"
                ;;
            wyrm__subcmd__help,help)
                cmd="wyrm__subcmd__help__subcmd__help"
                ;;
            wyrm__subcmd__help,netcheck)
                cmd="wyrm__subcmd__help__subcmd__netcheck"
                ;;
            wyrm__subcmd__help,receive)
                cmd="wyrm__subcmd__help__subcmd__receive"
                ;;
            wyrm__subcmd__help,send)
                cmd="wyrm__subcmd__help__subcmd__send"
                ;;
            wyrm__subcmd__help,shim)
                cmd="wyrm__subcmd__help__subcmd__shim"
                ;;
            *)
                ;;
        esac
    done

    case "${cmd}" in
        wyrm)
            opts="-h -V --relay-url --transit-helper --no-listen --hide-progress --ascii --force-classic --force-iroh --iroh-relays --update --help --version send receive netcheck shim help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --relay-url)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --transit-helper)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --iroh-relays)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__help)
            opts="send receive netcheck shim help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__help__subcmd__help)
            opts=""
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__help__subcmd__netcheck)
            opts=""
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__help__subcmd__receive)
            opts=""
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__help__subcmd__send)
            opts=""
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__help__subcmd__shim)
            opts=""
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__netcheck)
            opts="-h --relay-url --transit-helper --no-listen --hide-progress --ascii --force-classic --force-iroh --iroh-relays --help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --relay-url)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --transit-helper)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --iroh-relays)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__receive)
            opts="-o -h --allocate --new --code-length --accept-file --output-file --overwrite --relay-url --transit-helper --no-listen --hide-progress --ascii --force-classic --force-iroh --iroh-relays --help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --code-length)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --output-file)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -o)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --relay-url)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --transit-helper)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --iroh-relays)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__send)
            opts="-R -h --text --relative --code-length --code --qr --times --relay-url --transit-helper --no-listen --hide-progress --ascii --force-classic --force-iroh --iroh-relays --help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --text)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --code-length)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --code)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --times)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --relay-url)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --transit-helper)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --iroh-relays)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        wyrm__subcmd__shim)
            opts="-h --remove --dir --relay-url --transit-helper --no-listen --hide-progress --ascii --force-classic --force-iroh --iroh-relays --help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --dir)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --relay-url)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --transit-helper)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --iroh-relays)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
    esac
}

if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
    complete -F _wyrm -o nosort -o bashdefault -o default wyrm
else
    complete -F _wyrm -o bashdefault -o default wyrm
fi
