_mq() {
    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="mq"
                ;;
            mq,completion)
                cmd="mq__subcmd__completion"
                ;;
            mq,help)
                cmd="mq__subcmd__help"
                ;;
            mq,repl)
                cmd="mq__subcmd__repl"
                ;;
            *)
                ;;
        esac
    done

    case "${cmd}" in
        mq)
            opts="-A -f -I -L -M -m -N -R -W -E -a -F -U -S -o -C -B -e -c -P -O -h -V --aggregate --from-file --input-format --directory --module-names --import-module-names --args --argjson --rawfile --slurpfile --stream --watch --eval-all --allow-http-import --allowed-domain --refresh-modules --clear-cache --no-lockfile --frozen --lockfile --allow-net --allow-read --allow-write --allow-run --allow-env --allow-all --output-format --update --diff --unbuffered --list-style --link-title-style --link-url-style --separator --output --color-output --before-context --after-context --context --exit-status --count --skip --limit --no-position --list --argv --optimize-level --timeout --help --version repl completion help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --input-format)
                    COMPREPLY=($(compgen -W "markdown mdx html text null raw bytes cbor csv gron json psv toml toon tsv xml yaml" -- "${cur}"))
                    return 0
                    ;;
                -I)
                    COMPREPLY=($(compgen -W "markdown mdx html text null raw bytes cbor csv gron json psv toml toon tsv xml yaml" -- "${cur}"))
                    return 0
                    ;;
                --directory)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -L)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --module-names)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -M)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --import-module-names)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -m)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --args)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --argjson)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --rawfile)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --slurpfile)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allowed-domain)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --lockfile)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allow-net)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -N)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allow-read)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -R)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allow-write)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -W)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allow-run)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allow-env)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -E)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --output-format)
                    COMPREPLY=($(compgen -W "markdown html text json table grep gron raw csv toml toon xml yaml shell none" -- "${cur}"))
                    return 0
                    ;;
                -F)
                    COMPREPLY=($(compgen -W "markdown html text json table grep gron raw csv toml toon xml yaml shell none" -- "${cur}"))
                    return 0
                    ;;
                --list-style)
                    COMPREPLY=($(compgen -W "dash plus star" -- "${cur}"))
                    return 0
                    ;;
                --link-title-style)
                    COMPREPLY=($(compgen -W "double single paren" -- "${cur}"))
                    return 0
                    ;;
                --link-url-style)
                    COMPREPLY=($(compgen -W "none angle" -- "${cur}"))
                    return 0
                    ;;
                --separator)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -S)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --output)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -o)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --before-context)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -B)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --after-context)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --context)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --skip)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --limit)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -P)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --argv)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --optimize-level)
                    COMPREPLY=($(compgen -W "none basic full" -- "${cur}"))
                    return 0
                    ;;
                -O)
                    COMPREPLY=($(compgen -W "none basic full" -- "${cur}"))
                    return 0
                    ;;
                --timeout)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        mq__subcmd__completion)
            opts="-h --help bash elvish fish nushell 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
            ;;
        mq__subcmd__help)
            opts="-h --json --markdown --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
            ;;
        mq__subcmd__repl)
            opts="-h --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
            ;;
    esac
}

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