_bindgen() {
    local i cur prev opts cmd
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    cmd=""
    opts=""

    for i in ${COMP_WORDS[@]}
    do
        case "${cmd},${i}" in
            ",$1")
                cmd="bindgen"
                ;;
            *)
                ;;
        esac
    done

    case "${cmd}" in
        bindgen)
            opts="-o -V -h --depfile --default-enum-style --bitfield-enum --newtype-enum --newtype-global-enum --rustified-enum --constified-enum --constified-enum-module --default-macro-constant-type --default-alias-style --normal-alias --new-type-alias --new-type-alias-deref --default-non-copy-union-style --bindgen-wrapper-union --manually-drop-union --blocklist-type --blocklist-function --blocklist-item --blocklist-file --blocklist-var --no-layout-tests --no-derive-copy --no-derive-debug --no-derive-default --impl-debug --impl-partialeq --with-derive-default --with-derive-hash --with-derive-partialeq --with-derive-partialord --with-derive-eq --with-derive-ord --no-doc-comments --no-recursive-allowlist --objc-extern-crate --generate-block --generate-cstr --block-extern-crate --distrust-clang-mangling --builtins --ctypes-prefix --anon-fields-prefix --time-phases --emit-clang-ast --emit-ir --emit-ir-graphviz --enable-cxx-namespaces --disable-name-namespacing --disable-nested-struct-naming --disable-untagged-union --disable-header-comment --ignore-functions --generate --ignore-methods --no-convert-floats --no-prepend-enum-name --no-include-path-detection --fit-macro-constant-types --opaque-type --output --raw-line --module-raw-line --rust-target --use-core --conservative-inline-namespaces --allowlist-function --generate-inline-functions --allowlist-type --allowlist-var --allowlist-file --allowlist-item --verbose --dump-preprocessed-input --no-record-matches --no-size_t-is-usize --no-rustfmt-bindings --formatter --rustfmt-configuration-file --no-partialeq --no-copy --no-debug --no-default --no-hash --must-use-type --enable-function-attribute-detection --use-array-pointers-in-arguments --wasm-import-module-name --dynamic-loading --dynamic-link-require-all --prefix-link-name --respect-cxx-access-specs --translate-enum-integer-types --c-naming --explicit-padding --vtable-generation --sort-semantically --merge-extern-blocks --override-abi --wrap-unsafe-ops --with-derive-custom --with-derive-custom-struct --with-derive-custom-enum --with-derive-custom-union --wrap-static-fns --wrap-static-fns-path --wrap-static-fns-suffix --default-visibility --emit-diagnostics --generate-shell-completions --experimental --version --help [HEADER] [CLANG_ARGS]..."
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --depfile)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --default-enum-style)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --bitfield-enum)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --newtype-enum)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --newtype-global-enum)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --rustified-enum)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --constified-enum)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --constified-enum-module)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --default-macro-constant-type)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --default-alias-style)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --normal-alias)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --new-type-alias)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --new-type-alias-deref)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --default-non-copy-union-style)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --bindgen-wrapper-union)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --manually-drop-union)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --blocklist-type)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --blocklist-function)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --blocklist-item)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --blocklist-file)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --blocklist-var)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --ctypes-prefix)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --anon-fields-prefix)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --emit-ir-graphviz)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --generate)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --opaque-type)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --output)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                -o)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --raw-line)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --module-raw-line)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --rust-target)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allowlist-function)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allowlist-type)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allowlist-var)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allowlist-file)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --allowlist-item)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --formatter)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --rustfmt-configuration-file)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --no-partialeq)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --no-copy)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --no-debug)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --no-default)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --no-hash)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --must-use-type)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --wasm-import-module-name)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --dynamic-loading)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --prefix-link-name)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --override-abi)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --with-derive-custom)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --with-derive-custom-struct)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --with-derive-custom-enum)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --with-derive-custom-union)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --wrap-static-fns-path)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --wrap-static-fns-suffix)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --default-visibility)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --generate-shell-completions)
                    COMPREPLY=($(compgen -W "bash elvish fish powershell zsh" -- "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
    esac
}

complete -F _bindgen -o bashdefault -o default bindgen
