_espflash() {
    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="espflash"
                ;;
            espflash,board-info)
                cmd="espflash__board__info"
                ;;
            espflash,checksum-md5)
                cmd="espflash__checksum__md5"
                ;;
            espflash,completions)
                cmd="espflash__completions"
                ;;
            espflash,erase-flash)
                cmd="espflash__erase__flash"
                ;;
            espflash,erase-parts)
                cmd="espflash__erase__parts"
                ;;
            espflash,erase-region)
                cmd="espflash__erase__region"
                ;;
            espflash,flash)
                cmd="espflash__flash"
                ;;
            espflash,help)
                cmd="espflash__help"
                ;;
            espflash,hold-in-reset)
                cmd="espflash__hold__in__reset"
                ;;
            espflash,list-ports)
                cmd="espflash__list__ports"
                ;;
            espflash,monitor)
                cmd="espflash__monitor"
                ;;
            espflash,partition-table)
                cmd="espflash__partition__table"
                ;;
            espflash,read-flash)
                cmd="espflash__read__flash"
                ;;
            espflash,reset)
                cmd="espflash__reset"
                ;;
            espflash,save-image)
                cmd="espflash__save__image"
                ;;
            espflash,write-bin)
                cmd="espflash__write__bin"
                ;;
            espflash__help,board-info)
                cmd="espflash__help__board__info"
                ;;
            espflash__help,checksum-md5)
                cmd="espflash__help__checksum__md5"
                ;;
            espflash__help,completions)
                cmd="espflash__help__completions"
                ;;
            espflash__help,erase-flash)
                cmd="espflash__help__erase__flash"
                ;;
            espflash__help,erase-parts)
                cmd="espflash__help__erase__parts"
                ;;
            espflash__help,erase-region)
                cmd="espflash__help__erase__region"
                ;;
            espflash__help,flash)
                cmd="espflash__help__flash"
                ;;
            espflash__help,help)
                cmd="espflash__help__help"
                ;;
            espflash__help,hold-in-reset)
                cmd="espflash__help__hold__in__reset"
                ;;
            espflash__help,list-ports)
                cmd="espflash__help__list__ports"
                ;;
            espflash__help,monitor)
                cmd="espflash__help__monitor"
                ;;
            espflash__help,partition-table)
                cmd="espflash__help__partition__table"
                ;;
            espflash__help,read-flash)
                cmd="espflash__help__read__flash"
                ;;
            espflash__help,reset)
                cmd="espflash__help__reset"
                ;;
            espflash__help,save-image)
                cmd="espflash__help__save__image"
                ;;
            espflash__help,write-bin)
                cmd="espflash__help__write__bin"
                ;;
            *)
                ;;
        esac
    done

    case "${cmd}" in
        espflash)
            opts="-S -h -V --skip-update-check --help --version board-info checksum-md5 completions erase-flash erase-parts erase-region flash hold-in-reset list-ports monitor partition-table read-flash reset save-image write-bin help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__board__info)
            opts="-a -B -b -c -p -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --skip-update-check --help --version"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__checksum__md5)
            opts="-a -B -b -c -p -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --skip-update-check --help --version <ADDRESS> <SIZE>"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__completions)
            opts="-S -h -V --skip-update-check --help --version bash elvish fish powershell zsh"
            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
            ;;
        espflash__erase__flash)
            opts="-a -B -b -c -p -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --skip-update-check --help --version"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__erase__parts)
            opts="-a -B -b -c -p -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --partition-table --skip-update-check --help --version [LABELS]..."
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --partition-table)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__erase__region)
            opts="-a -B -b -c -p -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --skip-update-check --help --version <ADDRESS> <SIZE>"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__flash)
            opts="-a -B -b -c -p -f -m -s -M -r -L -F -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --flash-freq --flash-mode --flash-size --monitor --monitor-baud --elf --no-reset --log-format --output-format --processors --ram --no-verify --no-skip --min-chip-rev --mmu-page-size --check-app-descriptor --erase-parts --erase-data-parts --format --bootloader --partition-table --partition-table-offset --target-app-partition --skip-update-check --help --version <IMAGE>"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --flash-freq)
                    COMPREPLY=($(compgen -W "12mhz 15mhz 16mhz 20mhz 24mhz 26mhz 30mhz 40mhz 48mhz 60mhz 80mhz" -- "${cur}"))
                    return 0
                    ;;
                -f)
                    COMPREPLY=($(compgen -W "12mhz 15mhz 16mhz 20mhz 24mhz 26mhz 30mhz 40mhz 48mhz 60mhz 80mhz" -- "${cur}"))
                    return 0
                    ;;
                --flash-mode)
                    COMPREPLY=($(compgen -W "qio qout dio dout" -- "${cur}"))
                    return 0
                    ;;
                -m)
                    COMPREPLY=($(compgen -W "qio qout dio dout" -- "${cur}"))
                    return 0
                    ;;
                --flash-size)
                    COMPREPLY=($(compgen -W "256kb 512kb 1mb 2mb 4mb 8mb 16mb 32mb 64mb 128mb 256mb" -- "${cur}"))
                    return 0
                    ;;
                -s)
                    COMPREPLY=($(compgen -W "256kb 512kb 1mb 2mb 4mb 8mb 16mb 32mb 64mb 128mb 256mb" -- "${cur}"))
                    return 0
                    ;;
                --monitor-baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -r)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --elf)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-format)
                    COMPREPLY=($(compgen -W "defmt serial" -- "${cur}"))
                    return 0
                    ;;
                -L)
                    COMPREPLY=($(compgen -W "defmt serial" -- "${cur}"))
                    return 0
                    ;;
                --output-format)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -F)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --processors)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --min-chip-rev)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --mmu-page-size)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --erase-parts)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --erase-data-parts)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --format)
                    COMPREPLY=($(compgen -W "esp-idf" -- "${cur}"))
                    return 0
                    ;;
                --bootloader)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --partition-table)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --partition-table-offset)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --target-app-partition)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__help)
            opts="board-info checksum-md5 completions erase-flash erase-parts erase-region flash hold-in-reset list-ports monitor partition-table read-flash reset save-image write-bin 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
            ;;
        espflash__help__board__info)
            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
            ;;
        espflash__help__checksum__md5)
            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
            ;;
        espflash__help__completions)
            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
            ;;
        espflash__help__erase__flash)
            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
            ;;
        espflash__help__erase__parts)
            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
            ;;
        espflash__help__erase__region)
            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
            ;;
        espflash__help__flash)
            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
            ;;
        espflash__help__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
            ;;
        espflash__help__hold__in__reset)
            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
            ;;
        espflash__help__list__ports)
            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
            ;;
        espflash__help__monitor)
            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
            ;;
        espflash__help__partition__table)
            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
            ;;
        espflash__help__read__flash)
            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
            ;;
        espflash__help__reset)
            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
            ;;
        espflash__help__save__image)
            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
            ;;
        espflash__help__write__bin)
            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
            ;;
        espflash__hold__in__reset)
            opts="-a -B -b -c -p -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --skip-update-check --help --version"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__list__ports)
            opts="-a -n -S -h -V --list-all-ports --name-only --skip-update-check --help --version"
            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
            ;;
        espflash__monitor)
            opts="-a -B -b -c -p -r -L -F -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --monitor-baud --elf --no-reset --log-format --output-format --processors --skip-update-check --help --version"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --monitor-baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -r)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --elf)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-format)
                    COMPREPLY=($(compgen -W "defmt serial" -- "${cur}"))
                    return 0
                    ;;
                -L)
                    COMPREPLY=($(compgen -W "defmt serial" -- "${cur}"))
                    return 0
                    ;;
                --output-format)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -F)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --processors)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__partition__table)
            opts="-o -S -h -V --output --to-binary --to-csv --skip-update-check --help --version <FILE>"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --output)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -o)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__read__flash)
            opts="-a -B -b -c -p -S -h -V --block-size --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --max-in-flight --skip-update-check --help --version <ADDRESS> <SIZE> <FILE>"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --block-size)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --max-in-flight)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__reset)
            opts="-a -B -b -c -p -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --skip-update-check --help --version"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__save__image)
            opts="-f -m -s -x -S -h -V --flash-freq --flash-mode --flash-size --chip --merge --skip-padding --xtal-freq --min-chip-rev --mmu-page-size --check-app-descriptor --format --bootloader --partition-table --partition-table-offset --target-app-partition --skip-update-check --help --version <IMAGE> <FILE>"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --flash-freq)
                    COMPREPLY=($(compgen -W "12mhz 15mhz 16mhz 20mhz 24mhz 26mhz 30mhz 40mhz 48mhz 60mhz 80mhz" -- "${cur}"))
                    return 0
                    ;;
                -f)
                    COMPREPLY=($(compgen -W "12mhz 15mhz 16mhz 20mhz 24mhz 26mhz 30mhz 40mhz 48mhz 60mhz 80mhz" -- "${cur}"))
                    return 0
                    ;;
                --flash-mode)
                    COMPREPLY=($(compgen -W "qio qout dio dout" -- "${cur}"))
                    return 0
                    ;;
                -m)
                    COMPREPLY=($(compgen -W "qio qout dio dout" -- "${cur}"))
                    return 0
                    ;;
                --flash-size)
                    COMPREPLY=($(compgen -W "256kb 512kb 1mb 2mb 4mb 8mb 16mb 32mb 64mb 128mb 256mb" -- "${cur}"))
                    return 0
                    ;;
                -s)
                    COMPREPLY=($(compgen -W "256kb 512kb 1mb 2mb 4mb 8mb 16mb 32mb 64mb 128mb 256mb" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --xtal-freq)
                    COMPREPLY=($(compgen -W "26mhz 32mhz 40mhz 48mhz" -- "${cur}"))
                    return 0
                    ;;
                -x)
                    COMPREPLY=($(compgen -W "26mhz 32mhz 40mhz 48mhz" -- "${cur}"))
                    return 0
                    ;;
                --min-chip-rev)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --mmu-page-size)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --format)
                    COMPREPLY=($(compgen -W "esp-idf" -- "${cur}"))
                    return 0
                    ;;
                --bootloader)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --partition-table)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --partition-table-offset)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --target-app-partition)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        espflash__write__bin)
            opts="-a -B -b -c -p -M -r -L -F -S -h -V --after --baud --before --chip --confirm-port --list-all-ports --no-stub --port --non-interactive --monitor --monitor-baud --elf --no-reset --log-format --output-format --processors --skip-update-check --help --version <ADDRESS> <FILE>"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --after)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                -a)
                    COMPREPLY=($(compgen -W "hard-reset no-reset no-reset-no-stub watchdog-reset" -- "${cur}"))
                    return 0
                    ;;
                --baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                -b)
                    COMPREPLY=($(compgen -W "default-reset no-reset no-reset-no-sync usb-reset" -- "${cur}"))
                    return 0
                    ;;
                --chip)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                -c)
                    COMPREPLY=($(compgen -W "esp32 esp32c2 esp32c3 esp32c5 esp32c6 esp32h2 esp32p4 esp32s2 esp32s3" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -p)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --monitor-baud)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -r)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --elf)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-format)
                    COMPREPLY=($(compgen -W "defmt serial" -- "${cur}"))
                    return 0
                    ;;
                -L)
                    COMPREPLY=($(compgen -W "defmt serial" -- "${cur}"))
                    return 0
                    ;;
                --output-format)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -F)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --processors)
                    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 _espflash -o nosort -o bashdefault -o default espflash
else
    complete -F _espflash -o bashdefault -o default espflash
fi
