# Bash completion script for brew(1)
# This file is automatically generated by running `brew generate-man-completions`.
# See Library/Homebrew/completions/bash.erb for editing instructions.

if [[ -n ${POSIXLY_CORRECT:-} ]] || shopt -oq posix
then
  echo "Homebrew Bash completions do not work in POSIX mode" 1>&2
  return
fi

__brewcomp_words_include() {
  local element idx
  for (( idx = 1; idx < COMP_CWORD; idx++ ))
  do
    element=${COMP_WORDS[idx]}
    [[ -n ${element} && ${element} == "$1" ]] && return 0
  done
  return 1
}

__brewcomp() {
  # break $1 on space, tab, and newline characters,
  # and turn it into a newline separated list of words
  local list s sep=$'\n' IFS=$' \t\n'
  local cur=${COMP_WORDS[COMP_CWORD]}

  for s in $1
  do
    __brewcomp_words_include "${s}" || list+="${s}${sep}"
  done

  list=${list%"${sep}"}

  IFS="${sep}"
  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${list}" -- "${cur}")
}

# Don't use __brewcomp() in any of the __brew_complete_foo functions, as
# it is too slow and is not worth it just for duplicate elimination.
__brew_complete_formulae() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local formulae
  formulae="$(brew formulae)"
  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${formulae}" -- "${cur}")
}

__brew_complete_casks() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local casks
  casks="$(brew casks)"
  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${casks}" -- "${cur}")
}

__brew_complete_installed_formulae() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local installed_formulae
  installed_formulae="$(command ls "${HOMEBREW_CELLAR:-$(brew --cellar)}" 2>/dev/null)"
  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${installed_formulae}" -- "${cur}")
}

__brew_complete_installed_casks() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local installed_casks
  installed_casks="$(command ls "$(brew --caskroom)" 2>/dev/null)"
  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${installed_casks}" -- "${cur}")
}

__brew_complete_outdated_formulae() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local outdated_formulae
  outdated_formulae="$(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula --quiet)"
  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${outdated_formulae}" -- "${cur}")
}

__brew_complete_outdated_casks() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local outdated_casks
  outdated_casks="$(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask --quiet 2>/dev/null)"
  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${outdated_casks}" -- "${cur}")
}

__brew_complete_tapped() {
  local dir taps taplib
  taplib=${HOMEBREW_REPOSITORY:-$(brew --repository)}/Library/Taps

  for dir in "${taplib}"/*/*
  do
    [[ -d ${dir} ]] || continue
    dir=${dir#"${taplib}"/}
    dir=${dir/homebrew-/}
    taps+=" ${dir}"
  done
  __brewcomp "${taps}"
}

__brew_complete_commands() {
  # Auto-complete Homebrew commands

  local cur="${COMP_WORDS[COMP_CWORD]}"
  local cmds
  local -a cmd_aliases

  if [[ -n ${__HOMEBREW_COMMANDS} ]]
  then
    cmds=${__HOMEBREW_COMMANDS}
  elif [[ -n ${HOMEBREW_CACHE:-} && -f ${HOMEBREW_CACHE}/all_commands_list.txt ]]
  then
    cmds="$(< "${HOMEBREW_CACHE}/all_commands_list.txt")"
  elif [[ -n ${HOMEBREW_REPOSITORY:-} && -f ${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt ]]
  then
    cmds="$(< "${HOMEBREW_REPOSITORY}/completions/internal_commands_list.txt")"
  fi
  while read -r alias; do cmd_aliases+=("${alias}"); done < <(compgen -W "$(__brew_list_aliases)")
  [[ -n ${cmd_aliases[*]+"${cmd_aliases[*]}"} ]] && cmds+=" ${cmd_aliases[*]} alias unalias"
  while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${cmds}" -- "${cur}")
  export __HOMEBREW_COMMANDS=${cmds}
}

# compopt is only available in newer versions of bash
__brew_complete_files() {
  command -v compopt &> /dev/null && compopt -o default
}

# https://github.com/Homebrew/homebrew-aliases
__brew_list_aliases() {
  local aliases_dir="${HOME}/.brew-aliases"
  local pattern="^# alias: brew ([[:alnum:]-]+)$"
  local -a aliases

  [[ ! -d ${aliases_dir} ]] && return

  for file in "${aliases_dir}"/*; do
    [[ ! -f ${file} ]] && continue
    while read -r line; do
      if [[ ${line} =~ ${pattern} ]]; then
        aliases+=("${BASH_REMATCH[1]}")
        break
      fi
    done < "${file}"
  done
  [[ -n ${aliases[*]+"${aliases[*]}"} ]] && echo "${aliases[@]}"
}

_brew___cache() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --HEAD
      --arch
      --bottle-tag
      --build-from-source
      --cask
      --debug
      --force-bottle
      --formula
      --help
      --os
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew___caskroom() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_casks
}

_brew___cellar() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew___config() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew___env() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --plain
      --quiet
      --shell
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew___prefix() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --installed
      --quiet
      --unbrewed
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew___repo() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_tapped
}

_brew___repository() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_tapped
}

_brew___version() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew__s() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --archlinux
      --cask
      --closed
      --debian
      --debug
      --desc
      --eval-all
      --fedora
      --fink
      --formula
      --help
      --macports
      --open
      --opensuse
      --pull-request
      --quiet
      --repology
      --ubuntu
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew__v() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_abv() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --analytics
      --cask
      --category
      --days
      --debug
      --eval-all
      --fetch-manifest
      --formula
      --github
      --help
      --installed
      --json
      --quiet
      --variations
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_alias() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --edit
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_analytics() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brewcomp "state on off regenerate-uuid"
}

_brew_audit() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --arch
      --audit-debug
      --cask
      --debug
      --display-filename
      --eval-all
      --except
      --except-cops
      --fix
      --formula
      --git
      --help
      --installed
      --new
      --no-signing
      --online
      --only
      --only-cops
      --os
      --quiet
      --signing
      --skip-style
      --strict
      --tap
      --token-conflicts
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_autoremove() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dry-run
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_bottle() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --committer
      --debug
      --force-core-tap
      --help
      --json
      --keep-old
      --merge
      --no-all-checks
      --no-commit
      --no-rebuild
      --only-json-tab
      --quiet
      --root-url
      --root-url-using
      --skip-relocation
      --verbose
      --write
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_files
}

_brew_bump() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --bump-synced
      --cask
      --debug
      --eval-all
      --formula
      --full-name
      --help
      --installed
      --no-autobump
      --no-fork
      --no-pull-requests
      --open-pr
      --quiet
      --repology
      --start-with
      --tap
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_bump_cask_pr() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --commit
      --debug
      --dry-run
      --fork-org
      --help
      --message
      --no-audit
      --no-browse
      --no-fork
      --no-style
      --quiet
      --sha256
      --url
      --verbose
      --version
      --version-arm
      --version-intel
      --write-only
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_casks
}

_brew_bump_formula_pr() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --commit
      --debug
      --dry-run
      --force
      --fork-org
      --help
      --install-dependencies
      --message
      --mirror
      --no-audit
      --no-browse
      --no-fork
      --online
      --python-exclude-packages
      --python-extra-packages
      --python-package-name
      --quiet
      --revision
      --sha256
      --strict
      --tag
      --url
      --verbose
      --version
      --write-only
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_bump_revision() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dry-run
      --help
      --message
      --quiet
      --remove-bottle-block
      --verbose
      --write-only
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_bump_unversioned_casks() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dry-run
      --help
      --limit
      --quiet
      --state-file
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_casks
  __brew_complete_tapped
}

_brew_bundle() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --all
      --cask
      --check
      --cleanup
      --debug
      --describe
      --file
      --force
      --formula
      --global
      --help
      --install
      --mas
      --no-restart
      --no-upgrade
      --no-vscode
      --quiet
      --services
      --tap
      --upgrade
      --upgrade-formulae
      --verbose
      --vscode
      --whalebrew
      --zap
      "
      return
      ;;
    *) ;;
  esac
  __brewcomp "install dump cleanup check exec list sh env edit"
}

_brew_casks() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_cat() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --formula
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_cleanup() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dry-run
      --help
      --prune
      --prune-prefix
      --quiet
      --scrub
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_command() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_commands
}

_brew_commands() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --include-aliases
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_completions() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brewcomp "state link unlink"
}

_brew_config() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_contributions() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --csv
      --debug
      --from
      --help
      --quiet
      --repositories
      --to
      --user
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_create() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --HEAD
      --autotools
      --cask
      --cmake
      --crystal
      --debug
      --force
      --go
      --help
      --meson
      --no-fetch
      --node
      --perl
      --python
      --quiet
      --ruby
      --rust
      --set-license
      --set-name
      --set-version
      --tap
      --verbose
      --zig
      "
      return
      ;;
    *) ;;
  esac
}

_brew_debugger() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --open
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_commands
}

_brew_deps() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --HEAD
      --annotate
      --arch
      --cask
      --debug
      --direct
      --dot
      --eval-all
      --for-each
      --formula
      --full-name
      --graph
      --help
      --include-build
      --include-implicit
      --include-optional
      --include-requirements
      --include-test
      --installed
      --missing
      --os
      --quiet
      --skip-recommended
      --topological
      --tree
      --union
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_desc() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --description
      --eval-all
      --formula
      --help
      --name
      --quiet
      --search
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_determine_test_runners() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --all-supported
      --debug
      --dependents
      --eval-all
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_developer() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brewcomp "state on off"
}

_brew_dispatch_build_bottle() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --issue
      --linux
      --linux-arm64
      --linux-self-hosted
      --linux-wheezy
      --macos
      --quiet
      --tap
      --timeout
      --upload
      --verbose
      --workflow
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_docs() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_doctor() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --audit-debug
      --debug
      --help
      --list-checks
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brewcomp "${__HOMEBREW_DOCTOR_CHECKS=$(brew doctor --list-checks)}"
}

_brew_dr() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --audit-debug
      --debug
      --help
      --list-checks
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brewcomp "${__HOMEBREW_DOCTOR_CHECKS=$(brew doctor --list-checks)}"
}

_brew_edit() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --formula
      --help
      --print-path
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
  __brew_complete_tapped
}

_brew_environment() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --plain
      --quiet
      --shell
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_extract() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --force
      --git-revision
      --help
      --quiet
      --verbose
      --version
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_tapped
}

_brew_fetch() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --HEAD
      --arch
      --bottle-tag
      --build-bottle
      --build-from-source
      --cask
      --debug
      --deps
      --force
      --force-bottle
      --formula
      --help
      --no-quarantine
      --os
      --quarantine
      --quiet
      --retry
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_formula() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_formula_analytics() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --all-core-formulae-json
      --brew-command-run
      --brew-command-run-options
      --brew-test-bot-test
      --build-error
      --cask-install
      --days-ago
      --debug
      --help
      --homebrew-devcmdrun-developer
      --homebrew-os-arch-ci
      --homebrew-prefixes
      --homebrew-versions
      --install
      --install-on-request
      --json
      --os-version
      --quiet
      --setup
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_formulae() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_generate_analytics_api() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_generate_cask_api() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dry-run
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_generate_cask_ci_matrix() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --help
      --new
      --quiet
      --skip-install
      --syntax-only
      --url
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_casks
}

_brew_generate_formula_api() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dry-run
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_generate_man_completions() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_gist_logs() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --new-issue
      --private
      --quiet
      --verbose
      --with-hostname
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_home() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --formula
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_homepage() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --formula
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_info() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --analytics
      --cask
      --category
      --days
      --debug
      --eval-all
      --fetch-manifest
      --formula
      --github
      --help
      --installed
      --json
      --quiet
      --variations
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_instal() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --HEAD
      --adopt
      --appdir
      --as-dependency
      --ask
      --audio-unit-plugindir
      --binaries
      --bottle-arch
      --build-bottle
      --build-from-source
      --cask
      --cc
      --colorpickerdir
      --debug
      --debug-symbols
      --dictionarydir
      --display-times
      --dry-run
      --fetch-HEAD
      --fontdir
      --force
      --force-bottle
      --formula
      --git
      --help
      --ignore-dependencies
      --include-test
      --input-methoddir
      --interactive
      --internet-plugindir
      --keep-tmp
      --keyboard-layoutdir
      --language
      --mdimporterdir
      --no-binaries
      --no-quarantine
      --only-dependencies
      --overwrite
      --prefpanedir
      --qlplugindir
      --quarantine
      --quiet
      --require-sha
      --screen-saverdir
      --servicedir
      --skip-cask-deps
      --skip-link
      --skip-post-install
      --verbose
      --vst-plugindir
      --vst3-plugindir
      --zap
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_install() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --HEAD
      --adopt
      --appdir
      --as-dependency
      --ask
      --audio-unit-plugindir
      --binaries
      --bottle-arch
      --build-bottle
      --build-from-source
      --cask
      --cc
      --colorpickerdir
      --debug
      --debug-symbols
      --dictionarydir
      --display-times
      --dry-run
      --fetch-HEAD
      --fontdir
      --force
      --force-bottle
      --formula
      --git
      --help
      --ignore-dependencies
      --include-test
      --input-methoddir
      --interactive
      --internet-plugindir
      --keep-tmp
      --keyboard-layoutdir
      --language
      --mdimporterdir
      --no-binaries
      --no-quarantine
      --only-dependencies
      --overwrite
      --prefpanedir
      --qlplugindir
      --quarantine
      --quiet
      --require-sha
      --screen-saverdir
      --servicedir
      --skip-cask-deps
      --skip-link
      --skip-post-install
      --verbose
      --vst-plugindir
      --vst3-plugindir
      --zap
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_install_bundler_gems() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --add-groups
      --debug
      --groups
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_irb() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --examples
      --help
      --pry
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_lc() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --autobump
      --cask
      --debug
      --eval-all
      --extract-plist
      --formula
      --full-name
      --help
      --installed
      --json
      --newer-only
      --quiet
      --resources
      --tap
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_leaves() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --installed-as-dependency
      --installed-on-request
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_link() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --HEAD
      --debug
      --dry-run
      --force
      --help
      --overwrite
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
}

_brew_linkage() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cached
      --debug
      --help
      --quiet
      --reverse
      --strict
      --test
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
}

_brew_list() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --built-from-source
      --cask
      --debug
      --formula
      --full-name
      --help
      --installed-as-dependency
      --installed-on-request
      --multiple
      --pinned
      --poured-from-bottle
      --quiet
      --verbose
      --versions
      -1
      -l
      -r
      -t
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_installed_casks
}

_brew_livecheck() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --autobump
      --cask
      --debug
      --eval-all
      --extract-plist
      --formula
      --full-name
      --help
      --installed
      --json
      --newer-only
      --quiet
      --resources
      --tap
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_ln() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --HEAD
      --debug
      --dry-run
      --force
      --help
      --overwrite
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
}

_brew_log() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --formula
      --help
      --max-count
      --oneline
      --patch
      --quiet
      --stat
      --verbose
      -1
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_ls() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --built-from-source
      --cask
      --debug
      --formula
      --full-name
      --help
      --installed-as-dependency
      --installed-on-request
      --multiple
      --pinned
      --poured-from-bottle
      --quiet
      --verbose
      --versions
      -1
      -l
      -r
      -t
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_installed_casks
}

_brew_migrate() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --dry-run
      --force
      --formula
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_installed_casks
}

_brew_missing() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --hide
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_nodenv_sync() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_options() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --command
      --compact
      --debug
      --eval-all
      --help
      --installed
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_outdated() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --fetch-HEAD
      --formula
      --greedy
      --greedy-auto-updates
      --greedy-latest
      --help
      --json
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_pin() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
}

_brew_post_install() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
}

_brew_postinstall() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
}

_brew_pr_automerge() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --autosquash
      --debug
      --help
      --ignore-failures
      --publish
      --quiet
      --tap
      --verbose
      --with-label
      --without-approval
      --without-labels
      --workflow
      "
      return
      ;;
    *) ;;
  esac
}

_brew_pr_publish() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --autosquash
      --branch
      --debug
      --help
      --large-runner
      --message
      --quiet
      --tap
      --verbose
      --workflow
      "
      return
      ;;
    *) ;;
  esac
}

_brew_pr_pull() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --artifact-pattern
      --autosquash
      --branch-okay
      --clean
      --committer
      --debug
      --dry-run
      --help
      --ignore-missing-artifacts
      --keep-old
      --message
      --no-cherry-pick
      --no-commit
      --no-upload
      --quiet
      --resolve
      --retain-bottle-dir
      --root-url
      --root-url-using
      --tap
      --verbose
      --warn-on-upload-failure
      --workflows
      "
      return
      ;;
    *) ;;
  esac
}

_brew_pr_upload() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --committer
      --debug
      --dry-run
      --help
      --keep-old
      --no-commit
      --quiet
      --root-url
      --root-url-using
      --upload-only
      --verbose
      --warn-on-upload-failure
      "
      return
      ;;
    *) ;;
  esac
}

_brew_prof() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --stackprof
      --verbose
      --vernier
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_commands
}

_brew_pyenv_sync() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_rbenv_sync() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_readall() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --aliases
      --arch
      --debug
      --eval-all
      --help
      --no-simulate
      --os
      --quiet
      --syntax
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_tapped
}

_brew_reinstall() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --adopt
      --appdir
      --ask
      --audio-unit-plugindir
      --binaries
      --build-from-source
      --cask
      --colorpickerdir
      --debug
      --debug-symbols
      --dictionarydir
      --display-times
      --fontdir
      --force
      --force-bottle
      --formula
      --git
      --help
      --input-methoddir
      --interactive
      --internet-plugindir
      --keep-tmp
      --keyboard-layoutdir
      --language
      --mdimporterdir
      --no-binaries
      --no-quarantine
      --prefpanedir
      --qlplugindir
      --quarantine
      --quiet
      --require-sha
      --screen-saverdir
      --servicedir
      --skip-cask-deps
      --verbose
      --vst-plugindir
      --vst3-plugindir
      --zap
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_release() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --major
      --minor
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_remove() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --force
      --formula
      --help
      --ignore-dependencies
      --quiet
      --verbose
      --zap
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_installed_casks
}

_brew_rm() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --force
      --formula
      --help
      --ignore-dependencies
      --quiet
      --verbose
      --zap
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_installed_casks
}

_brew_rubocop() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_ruby() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      -e
      -r
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_files
}

_brew_rubydoc() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --only-public
      --open
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_search() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --archlinux
      --cask
      --closed
      --debian
      --debug
      --desc
      --eval-all
      --fedora
      --fink
      --formula
      --help
      --macports
      --open
      --opensuse
      --pull-request
      --quiet
      --repology
      --ubuntu
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_services() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --all
      --debug
      --file
      --help
      --json
      --keep
      --max-wait
      --no-wait
      --quiet
      --sudo-service-user
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brewcomp "list info run start stop kill restart cleanup"
}

_brew_setup_ruby() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_commands
}

_brew_sh() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cmd
      --debug
      --env
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_files
}

_brew_shellenv() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_style() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --except-cops
      --fix
      --formula
      --help
      --only-cops
      --quiet
      --reset-cache
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_files
  __brew_complete_tapped
  __brew_complete_formulae
  __brew_complete_casks
}

_brew_tab() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --formula
      --help
      --installed-on-request
      --no-installed-on-request
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_installed_casks
}

_brew_tap() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --custom-remote
      --debug
      --eval-all
      --force
      --help
      --quiet
      --repair
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_tapped
}

_brew_tap_info() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --installed
      --json
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_tapped
}

_brew_tap_new() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --branch
      --debug
      --github-packages
      --help
      --no-git
      --pull-label
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_tapped
}

_brew_tc() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dir
      --file
      --fix
      --help
      --ignore
      --lsp
      --quiet
      --suggest-typed
      --update
      --update-all
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_tapped
}

_brew_test() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --HEAD
      --debug
      --force
      --help
      --keep-tmp
      --quiet
      --retry
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
}

_brew_tests() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --changed
      --coverage
      --debug
      --fail-fast
      --generic
      --help
      --online
      --only
      --profile
      --quiet
      --seed
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_typecheck() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dir
      --file
      --fix
      --help
      --ignore
      --lsp
      --quiet
      --suggest-typed
      --update
      --update-all
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_tapped
}

_brew_unalias() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_unbottled() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dependents
      --eval-all
      --help
      --lost
      --quiet
      --tag
      --total
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_uninstal() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --force
      --formula
      --help
      --ignore-dependencies
      --quiet
      --verbose
      --zap
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_installed_casks
}

_brew_uninstall() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --force
      --formula
      --help
      --ignore-dependencies
      --quiet
      --verbose
      --zap
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_installed_casks
}

_brew_unlink() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --dry-run
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
}

_brew_unpack() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --destdir
      --force
      --git
      --help
      --patch
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_unpin() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
}

_brew_untap() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --force
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_tapped
}

_brew_up() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --auto-update
      --debug
      --force
      --help
      --merge
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_update() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --auto-update
      --debug
      --force
      --help
      --merge
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_update_if_needed() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_update_license_data() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_update_maintainers() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_update_python_resources() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --exclude-packages
      --extra-packages
      --help
      --ignore-errors
      --ignore-non-pypi-packages
      --install-dependencies
      --package-name
      --print-only
      --quiet
      --silent
      --verbose
      --version
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_update_report() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --auto-update
      --debug
      --force
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_update_reset() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_update_sponsors() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_update_test() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --before
      --commit
      --debug
      --help
      --keep-tmp
      --quiet
      --to-tag
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_upgrade() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --appdir
      --ask
      --audio-unit-plugindir
      --binaries
      --build-from-source
      --cask
      --colorpickerdir
      --debug
      --debug-symbols
      --dictionarydir
      --display-times
      --dry-run
      --fetch-HEAD
      --fontdir
      --force
      --force-bottle
      --formula
      --greedy
      --greedy-auto-updates
      --greedy-latest
      --help
      --input-methoddir
      --interactive
      --internet-plugindir
      --keep-tmp
      --keyboard-layoutdir
      --language
      --mdimporterdir
      --no-binaries
      --no-quarantine
      --overwrite
      --prefpanedir
      --qlplugindir
      --quarantine
      --quiet
      --require-sha
      --screen-saverdir
      --servicedir
      --skip-cask-deps
      --verbose
      --vst-plugindir
      --vst3-plugindir
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_installed_formulae
  __brew_complete_installed_casks
}

_brew_uses() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --cask
      --debug
      --eval-all
      --formula
      --help
      --include-build
      --include-implicit
      --include-optional
      --include-test
      --installed
      --missing
      --quiet
      --recursive
      --skip-recommended
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew_vendor_gems() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --no-commit
      --quiet
      --update
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_vendor_install() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --debug
      --help
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
}

_brew_verify() {
  local cur="${COMP_WORDS[COMP_CWORD]}"
  case "${cur}" in
    -*)
      __brewcomp "
      --arch
      --bottle-tag
      --debug
      --deps
      --force
      --help
      --json
      --os
      --quiet
      --verbose
      "
      return
      ;;
    *) ;;
  esac
  __brew_complete_formulae
}

_brew() {
  local i=1 cmd

  # find the subcommand
  while [[ "${i}" -lt "${COMP_CWORD}" ]]
  do
    local s="${COMP_WORDS[i]}"
    case "${s}" in
      --*)
        cmd="${s}"
        break
        ;;
      -*)
        ;;
      *)
        cmd="${s}"
        break
        ;;
    esac
    (( i++ ))
  done

  if [[ "${i}" -eq "${COMP_CWORD}" ]]
  then
    __brew_complete_commands
    return
  fi

  # subcommands have their own completion functions
  case "${cmd}" in
    --cache) _brew___cache ;;
    --caskroom) _brew___caskroom ;;
    --cellar) _brew___cellar ;;
    --config) _brew___config ;;
    --env) _brew___env ;;
    --prefix) _brew___prefix ;;
    --repo) _brew___repo ;;
    --repository) _brew___repository ;;
    --version) _brew___version ;;
    -S) _brew__s ;;
    -v) _brew__v ;;
    abv) _brew_abv ;;
    alias) _brew_alias ;;
    analytics) _brew_analytics ;;
    audit) _brew_audit ;;
    autoremove) _brew_autoremove ;;
    bottle) _brew_bottle ;;
    bump) _brew_bump ;;
    bump-cask-pr) _brew_bump_cask_pr ;;
    bump-formula-pr) _brew_bump_formula_pr ;;
    bump-revision) _brew_bump_revision ;;
    bump-unversioned-casks) _brew_bump_unversioned_casks ;;
    bundle) _brew_bundle ;;
    casks) _brew_casks ;;
    cat) _brew_cat ;;
    cleanup) _brew_cleanup ;;
    command) _brew_command ;;
    commands) _brew_commands ;;
    completions) _brew_completions ;;
    config) _brew_config ;;
    contributions) _brew_contributions ;;
    create) _brew_create ;;
    debugger) _brew_debugger ;;
    deps) _brew_deps ;;
    desc) _brew_desc ;;
    determine-test-runners) _brew_determine_test_runners ;;
    developer) _brew_developer ;;
    dispatch-build-bottle) _brew_dispatch_build_bottle ;;
    docs) _brew_docs ;;
    doctor) _brew_doctor ;;
    dr) _brew_dr ;;
    edit) _brew_edit ;;
    environment) _brew_environment ;;
    extract) _brew_extract ;;
    fetch) _brew_fetch ;;
    formula) _brew_formula ;;
    formula-analytics) _brew_formula_analytics ;;
    formulae) _brew_formulae ;;
    generate-analytics-api) _brew_generate_analytics_api ;;
    generate-cask-api) _brew_generate_cask_api ;;
    generate-cask-ci-matrix) _brew_generate_cask_ci_matrix ;;
    generate-formula-api) _brew_generate_formula_api ;;
    generate-man-completions) _brew_generate_man_completions ;;
    gist-logs) _brew_gist_logs ;;
    home) _brew_home ;;
    homepage) _brew_homepage ;;
    info) _brew_info ;;
    instal) _brew_instal ;;
    install) _brew_install ;;
    install-bundler-gems) _brew_install_bundler_gems ;;
    irb) _brew_irb ;;
    lc) _brew_lc ;;
    leaves) _brew_leaves ;;
    link) _brew_link ;;
    linkage) _brew_linkage ;;
    list) _brew_list ;;
    livecheck) _brew_livecheck ;;
    ln) _brew_ln ;;
    log) _brew_log ;;
    ls) _brew_ls ;;
    migrate) _brew_migrate ;;
    missing) _brew_missing ;;
    nodenv-sync) _brew_nodenv_sync ;;
    options) _brew_options ;;
    outdated) _brew_outdated ;;
    pin) _brew_pin ;;
    post_install) _brew_post_install ;;
    postinstall) _brew_postinstall ;;
    pr-automerge) _brew_pr_automerge ;;
    pr-publish) _brew_pr_publish ;;
    pr-pull) _brew_pr_pull ;;
    pr-upload) _brew_pr_upload ;;
    prof) _brew_prof ;;
    pyenv-sync) _brew_pyenv_sync ;;
    rbenv-sync) _brew_rbenv_sync ;;
    readall) _brew_readall ;;
    reinstall) _brew_reinstall ;;
    release) _brew_release ;;
    remove) _brew_remove ;;
    rm) _brew_rm ;;
    rubocop) _brew_rubocop ;;
    ruby) _brew_ruby ;;
    rubydoc) _brew_rubydoc ;;
    search) _brew_search ;;
    services) _brew_services ;;
    setup-ruby) _brew_setup_ruby ;;
    sh) _brew_sh ;;
    shellenv) _brew_shellenv ;;
    style) _brew_style ;;
    tab) _brew_tab ;;
    tap) _brew_tap ;;
    tap-info) _brew_tap_info ;;
    tap-new) _brew_tap_new ;;
    tc) _brew_tc ;;
    test) _brew_test ;;
    tests) _brew_tests ;;
    typecheck) _brew_typecheck ;;
    unalias) _brew_unalias ;;
    unbottled) _brew_unbottled ;;
    uninstal) _brew_uninstal ;;
    uninstall) _brew_uninstall ;;
    unlink) _brew_unlink ;;
    unpack) _brew_unpack ;;
    unpin) _brew_unpin ;;
    untap) _brew_untap ;;
    up) _brew_up ;;
    update) _brew_update ;;
    update-if-needed) _brew_update_if_needed ;;
    update-license-data) _brew_update_license_data ;;
    update-maintainers) _brew_update_maintainers ;;
    update-python-resources) _brew_update_python_resources ;;
    update-report) _brew_update_report ;;
    update-reset) _brew_update_reset ;;
    update-sponsors) _brew_update_sponsors ;;
    update-test) _brew_update_test ;;
    upgrade) _brew_upgrade ;;
    uses) _brew_uses ;;
    vendor-gems) _brew_vendor_gems ;;
    vendor-install) _brew_vendor_install ;;
    verify) _brew_verify ;;
    *) ;;
  esac
}

# keep around for compatibility
_brew_to_completion() {
  _brew
}

complete -o bashdefault -o default -F _brew brew
