#compdef brew
#autoload

# Brew ZSH completion function
# This file is automatically generated by running `brew generate-man-completions`.
# See Library/Homebrew/completions/zsh.erb for editing instructions.

# functions starting with __brew are helper functions that complete or list
#   various types of items.
# functions starting with _brew_ are completions for brew commands
#   this mechanism can be extended by external commands by defining a function
#   named _brew_<external-name>. See _brew_cask for an example of this.

# a list of aliased internal commands
__brew_list_aliases() {
  local -a aliases
  aliases=(
    ls list
    homepage home
    '-S' search
    up update
    ln link
    instal install
    uninstal uninstall
    post_install postinstall
    rm uninstall
    remove uninstall
    abv info
    dr doctor
    '--repo' '--repository'
    environment '--env'
    '--config' config
    '-v' '--version'
    lc livecheck
    tc typecheck
    x exec
  )
  echo "${aliases}"
}

__brew_user_aliases() {
  local aliases_dir="${HOME}/.config/brew-aliases"
  local pattern="alias: brew ([^[:space:]]+)"
  local file line alias_name
  local -a aliases

  [[ ! -d ${aliases_dir} ]] && aliases_dir="${HOME}/.brew-aliases"
  [[ ! -d ${aliases_dir} ]] && return

  for file in "${aliases_dir}"/*(N); do
    [[ ! -f ${file} || ${file} == *~ ]] && continue
    alias_name="${file:t}"
    {
      read -r line
      if read -r line && [[ ${line} =~ ${pattern} ]]; then
        alias_name="${match[1]}"
      fi
    } < "${file}"
    aliases+=("${alias_name}")
  done
  (( ${#aliases} )) && _describe -t user-aliases 'user aliases' aliases
}

__brew_formulae_or_ruby_files() {
  _alternative 'files:files:{_files -g "*.rb"}'
}

# completions remain in cache until any tap has new commits
__brew_completion_caching_policy() {
  local -a tmp

  # invalidate if cache file is missing or >=2 weeks old
  tmp=( $1(mw-2N) )
  (( $#tmp )) || return 0

  # otherwise, invalidate if latest tap index file is missing or newer than cache file
  tmp=( $(brew --repository)/Library/Taps/*/*/.git/index(om[1]N) )
  [[ -z $tmp || $tmp -nt $1 ]]
}

__brew_formulae() {
  [[ -prefix '-' ]] && return 0

  local -a list
  local comp_cachename=brew_formulae
  if ! _retrieve_cache $comp_cachename; then
    list=( $(HOMEBREW_COMPLETION=1 brew formulae) )
    _store_cache $comp_cachename list
  fi
  _describe -t formulae 'all formulae' list
}

__brew_installed_formulae() {
  [[ -prefix '-' ]] && return 0

  local -a formulae
  formulae=($(brew list --formula))
  _describe -t formulae 'installed formulae' formulae
}

__brew_outdated_formulae() {
  [[ -prefix '-' ]] && return 0

  local -a formulae
  formulae=($(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula))
  _describe -t formulae 'outdated formulae' formulae
}

__brew_casks() {
  [[ -prefix '-' ]] && return 0

  local -a list
  local expl
  local comp_cachename=brew_casks

  if ! _retrieve_cache $comp_cachename; then
    list=( $(HOMEBREW_COMPLETION=1 brew casks) )
    _store_cache $comp_cachename list
  fi

  _wanted list expl 'all casks' compadd -a list
}

__brew_installed_casks() {
  [[ -prefix '-' ]] && return 0

  local -a list
  local expl
  list=( $(brew list --cask 2>/dev/null) )
  _wanted list expl 'installed casks' compadd -a list
}

__brew_outdated_casks() {
  [[ -prefix '-' ]] && return 0

  local -a casks
  casks=($(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask 2>/dev/null))
  _describe -t casks 'outdated casks' casks
}

__brew_installed_taps() {
  [[ -prefix '-' ]] && return 0

  local -a taps
  taps=($(brew tap))
  _describe -t installed-taps 'installed taps' taps
}

__brew_any_tap() {
  [[ -prefix '-' ]] && return 0

  _alternative \
    'installed-taps:installed taps:__brew_installed_taps'
}

__brew_internal_commands() {
  local -a commands
  commands=(
    '--cache:Display Homebrew'\''s download cache'
    '--caskroom:Display Homebrew'\''s Caskroom path'
    '--cellar:Display Homebrew'\''s Cellar path'
    '--env:Summarise Homebrew'\''s build environment as a plain list'
    '--prefix:Display Homebrew'\''s install path'
    '--repository:Display where Homebrew'\''s Git repository is located'
    '--taps:Display the path to Homebrew’s Taps directory'
    '--version:Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask (if tapped) to standard output'
    'alias:Show an alias'\''s command'
    'as-console-user:Run a Homebrew command as the active macOS console user'
    'audit:Check formula or cask for Homebrew coding style violations'
    'autoremove:Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed'
    'bottle:Generate a bottle (binary package) from a formula that was installed with `--build-bottle`'
    'bump:Displays out-of-date packages and the latest version available'
    'bump-cask-pr:Create a pull request to update cask with a new version'
    'bump-compatibility-version:Create a commit to increment the compatibility_version of formula'
    'bump-formula-pr:Create a pull request to update formula with a new URL or a new tag'
    'bump-revision:Create a commit to increment the revision of formula'
    'bump-unversioned-casks:Check all casks with unversioned URLs in a given tap for updates'
    'bundle:Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask, Mac App Store dependencies, VSCode (and forks/variants) extensions, Go packages, Cargo packages, uv tools, Flatpak packages, WinGet packages, Krew plugins and npm packages'
    'casks:List all locally installable casks including short names'
    'cat:Display the source of a formula or cask'
    'cleanup:Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae'
    'command:Display the path to the file being used when invoking `brew` cmd'
    'command-not-found-init:Print instructions for setting up the command-not-found hook for your shell'
    'commands:Show lists of built-in and external commands'
    'completions:Control whether Homebrew automatically links external tap shell completion files'
    'config:Show Homebrew and system configuration info useful for debugging'
    'contributions:Summarise contributions to Homebrew repositories'
    'create:Generate a formula or, with `--cask`, a cask for the downloadable file at URL and open it in the editor'
    'debugger:Run the specified Homebrew command in debug mode'
    'deps:Show dependencies for formula'
    'desc:Display formula'\''s name and one-line description'
    'developer:Control Homebrew'\''s developer mode'
    'docs:Open Homebrew'\''s online documentation at https://docs.brew.sh in a browser'
    'doctor:Check your system for potential problems'
    'edit:Open a formula, cask or tap in the editor set by `$EDITOR` or `$HOMEBREW_EDITOR`, or open the Homebrew repository for editing if no argument is provided'
    'exec:Run command in an environment populated by Homebrew formulae'
    'extract:Look through repository history to find the most recent version of formula and create a copy in tap'
    'fetch:Download a bottle (if available) or source packages for formulae and binaries for casks'
    'formula:Display the path where formula is located'
    'formulae:List all locally installable formulae including short names'
    'generate-man-completions:Generate Homebrew'\''s manpages and shell completions'
    'generate-zap:Generate a `zap` stanza for a cask by scanning the system for associated files and directories'
    'gist-logs:Upload logs for a failed build of formula to a new Gist'
    'help:Outputs the usage instructions for `brew` command'
    'home:Open a formula or cask'\''s homepage in a browser, or open Homebrew'\''s own homepage if no argument is provided'
    'info:Display brief statistics for your Homebrew installation'
    'install:Install a formula or cask'
    'install-bundler-gems:Install Homebrew'\''s Bundler gems'
    'irb:Enter the interactive Homebrew Ruby shell'
    'leaves:List installed formulae that are not dependencies of another installed formula or cask'
    'lgtm:Run `brew typecheck`, `brew style --changed` and the relevant `brew tests`, `brew audit` and `brew test` checks in one go'
    'link:Symlink all of formula'\''s installed files into Homebrew'\''s prefix'
    'linkage:Check the library links from the given formula kegs'
    'list:List all installed formulae and casks'
    'livecheck:Check for newer versions of formulae and/or casks from upstream'
    'log:Show the `git log` for formula or cask, or show the log for the Homebrew repository if no formula or cask is provided'
    'mcp-server:Starts the Homebrew MCP (Model Context Protocol) server'
    'migrate:Migrate renamed packages to new names, where formula are old names of packages'
    'missing:Check the given formula kegs and cask installations for missing dependencies'
    'nodenv-sync:Create symlinks for Homebrew'\''s installed NodeJS versions in `~/.nodenv/versions`'
    'options:Show install options specific to formula'
    'outdated:List installed casks and formulae that have an updated version available'
    'pin:Pin the specified package, preventing it from being upgraded when issuing the `brew upgrade` formula or cask command'
    'postinstall:Rerun the post-install steps for formula'
    'prof:Run Homebrew with a Ruby profiler'
    'pyenv-sync:Create symlinks for Homebrew'\''s installed Python versions in `~/.pyenv/versions`'
    'rbenv-sync:Create symlinks for Homebrew'\''s installed Ruby versions in `~/.rbenv/versions`'
    'readall:Import all items from the specified tap, or from all installed taps if none is provided'
    'reinstall:Uninstall and then reinstall a formula or cask using the same options it was originally installed with, plus any appended options specific to a formula'
    'rubocop:Installs, configures and runs Homebrew'\''s `rubocop`'
    'ruby:Run a Ruby instance with Homebrew'\''s libraries loaded'
    'rubydoc:Generate Homebrew'\''s RubyDoc documentation'
    'sandbox-exec:Run command in Homebrew'\''s sandbox, allowing writes to writable-path and Homebrew'\''s temporary and cache directories'
    'search:Perform a substring search of cask tokens and formula names for text'
    'services:Manage background services with macOS'\'' `launchctl`(1) daemon manager or Linux'\''s `systemctl`(1) service manager'
    'setup-ruby:Installs and configures Homebrew'\''s Ruby'
    'setup-sandbox:Run any necessary commands to setup the Homebrew sandbox'
    'sh:Enter an interactive shell for Homebrew'\''s build environment'
    'shellenv:Valid shells: bash|csh|fish|pwsh|sh|tcsh|zsh  Print export statements'
    'source:Open a formula'\''s source repository in a browser, or open Homebrew'\''s own repository if no argument is provided'
    'style:Check formulae or files for conformance to Homebrew style guidelines'
    'tab:Edit tab information for installed formulae or casks'
    'tap:Tap a formula repository'
    'tap-info:Show detailed information about one or more taps'
    'tap-new:Generate the template files for a new tap'
    'test:Run the test method provided by an installed formula'
    'test-bot:Tests the full lifecycle of a Homebrew change to a tap (Git repository)'
    'tests:Run Homebrew'\''s unit and integration tests'
    'trust:Trust non-official tap formulae, casks or commands so Homebrew may load them when `$HOMEBREW_REQUIRE_TAP_TRUST` is set'
    'typecheck:Check for typechecking errors using Sorbet'
    'unalias:Remove aliases'
    'unbottled:Show the unbottled dependents of formulae'
    'uninstall:Uninstall a formula or cask'
    'unlink:Remove symlinks for formula from Homebrew'\''s prefix'
    'unpack:Unpack the files for the formula or cask into subdirectories of the current working directory'
    'unpin:Unpin the specified package, allowing it to be upgraded by `brew upgrade` formula or cask'
    'untap:Remove a tapped formula repository'
    'untrust:Stop trusting non-official tap formulae, casks or commands'
    'update:Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations'
    'update-if-needed:Runs `brew update --auto-update` only if needed'
    'update-perl-resources:Update versions for CPAN resource blocks in formula'
    'update-python-resources:Update versions for PyPI resource blocks in formula'
    'update-reset:Fetch and reset Homebrew and all tap repositories (or any specified repository) using `git`(1) to their latest `origin/HEAD`'
    'update-test:Run a test of `brew update` with a new repository clone'
    'upgrade:Upgrade outdated, unpinned packages using the same options they were originally installed with, plus any appended brew formula options'
    'uses:Show formulae and casks that specify formula as a dependency; that is, show dependents of formula'
    'vendor-gems:Install and commit Homebrew'\''s vendored gems'
    'verify:Verify the build provenance of bottles using GitHub'\''s attestation tools'
    'version-install:Extract a specific version of formula into a personal tap and install it'
    'which-formula:Show which formula(e) provides the given command'
    'which-update:Database update for `brew which-formula`'
  )
  if [[ -n ${HOMEBREW_DEVELOPER:-} ]]; then
    commands+=(
      'analytics:Control Homebrew'\''s anonymous aggregate user behaviour analytics'
      'determine-test-runners:Determines the runners used to test formulae or their dependents'
      'dispatch-build-bottle:Build bottles for these formulae with GitHub Actions'
      'formula-analytics:Query Homebrew'\''s analytics'
      'generate-analytics-api:Generates analytics API data files for https://formulae.brew.sh'
      'generate-cask-api:Generate `homebrew/cask` API data files for https://formulae.brew.sh'
      'generate-cask-ci-matrix:Generate a GitHub Actions matrix for a given pull request URL or list of cask names'
      'generate-formula-api:Generate `homebrew/core` API data files for https://formulae.brew.sh'
      'generate-internal-api:Generate internal API data files for https://formulae.brew.sh'
      'pr-automerge:Find pull requests that can be automatically merged using `brew pr-publish`'
      'pr-publish:Publish bottles for a pull request with GitHub Actions'
      'pr-pull:Download and publish bottles and apply the bottle commit from a pull request with artifacts generated by GitHub Actions'
      'pr-upload:Apply the bottle commit and publish bottles to a host'
      'release:Create a new draft Homebrew/brew release with the appropriate version number and release notes'
      'update-license-data:Update SPDX license data in the Homebrew repository'
      'update-maintainers:Update the list of maintainers in the `Homebrew/brew` README'
      'update-portable-ruby:Update the vendored `portable-ruby` from the current `portable-ruby` formula: write the version files and bottle checksums, run `brew vendor-install ruby`, then sync `utils/ruby.sh`, vendored gems and RBI files to the bundler shipped by the new ruby'
      'update-report:The Ruby implementation of `brew update`'
      'update-sponsors:Update the list of GitHub Sponsors in the `Homebrew/brew` README'
      'vendor-install:Install Homebrew'\''s portable Ruby'
    )
  fi
  _describe -t internal-commands 'internal commands' commands
}

__brew_external_commands() {
  local -a list
  local comp_cachename=brew_all_commands
  if ! _retrieve_cache $comp_cachename; then
    local cache_dir=$(brew --cache)
    [[ -f $cache_dir/external_commands_list.txt ]] &&
      list=( $(<$cache_dir/external_commands_list.txt) )
    _store_cache $comp_cachename list
  fi
  _describe -t all-commands 'all commands' list
}

__brew_commands() {
  _alternative \
    'internal-commands:command:__brew_internal_commands' \
    'external-commands:command:__brew_external_commands' \
    'user-aliases:alias:__brew_user_aliases'
}

__brew_diagnostic_checks() {
  local -a diagnostic_checks
  diagnostic_checks=($(brew doctor --list-checks))
  _describe -t diagnostic-checks 'diagnostic checks' diagnostic_checks
}

__brew_services() {
  [[ -prefix '-' ]] && return 0

  local -a services
  services=($(command find "$(brew --cellar)" -mindepth 3 -maxdepth 3 -name '*.service' \
    | awk -F'homebrew.|.service' '{print $3}' \
    | sort -d))
  _describe -t services 'services' services
}

# brew --cache
_brew___cache() {
  _arguments \
    '(--build-from-source --force-bottle --bottle-tag --cask)--HEAD[Show the cache file used when building from HEAD]' \
    '(--bottle-tag)--arch[Show cache file for the given CPU architecture. (Pass `all` to show cache files for all architectures.)]' \
    '(--build-from-source --force-bottle --HEAD --cask --os --arch)--bottle-tag[Show the cache file used when pouring a bottle for the given tag]' \
    '(--force-bottle --bottle-tag --HEAD --cask)--build-from-source[Show the cache file used when building from source]' \
    '--debug[Display any debugging information]' \
    '(--build-from-source --bottle-tag --HEAD --cask)--force-bottle[Show the cache file used when pouring a bottle]' \
    '--help[Show this message]' \
    '(--bottle-tag)--os[Show cache file for the given operating system. (Pass `all` to show cache files for all operating systems.)]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask)--formula[Only show cache files for formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--build-from-source --force-bottle --bottle-tag --HEAD --formula)--cask[Only show cache files for casks]' \
    '*:cask:__brew_casks'
}

# brew --caskroom
_brew___caskroom() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - cask \
    '*:cask:__brew_casks'
}

# brew --cellar
_brew___cellar() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew --env
_brew___env() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--plain[Generate plain output even when piped]' \
    '--quiet[Make some output more quiet]' \
    '--shell[Generate a list of environment variables for the specified shell, or `--shell=auto` to detect the current shell]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew --prefix
_brew___prefix() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '(--unbrewed)--installed[Outputs nothing and returns a failing status code if formula is not installed]' \
    '--quiet[Make some output more quiet]' \
    '(--installed)--unbrewed[List files in Homebrew'\''s prefix not installed by Homebrew]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew --repository
_brew___repository() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew --taps
_brew___taps() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew --version
_brew___version() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew alias
_brew_alias() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--edit[Edit aliases in a text editor. Either one or all aliases may be opened at once. If the given alias doesn'\''t exist it'\''ll be pre-populated with a template]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew analytics
_brew_analytics() {
  local state
  local -a subcommands
  subcommands=(
    'state:Display the current state of Homebrew'\''s analytics'
    'regenerate-uuid:Delete Homebrew'\''s legacy analytics UUID'
    'on:Turn Homebrew'\''s analytics on'
    'off:Turn Homebrew'\''s analytics off'
  )

  _arguments -C \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '1:subcommand:->subcommand' \
    '*::arg:->args'

  case "$state" in
    subcommand)
      _describe -t subcommands 'subcommand' subcommands
      ;;
    args)
      case "$words[1]" in
state)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
regenerate-uuid)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
on)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
off)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
        *) ;;
      esac
      ;;
  esac
}

# brew as-console-user
_brew_as_console_user() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew audit
_brew_audit() {
  _arguments \
    '--arch[Audit the given CPU architecture. (Pass `all` to audit all architectures.)]' \
    '--audit-debug[Enable debugging and profiling of audit methods]' \
    '(--installed --tap)--changed[Check files that were changed from the `main` branch]' \
    '--debug[Display any debugging information]' \
    '--display-filename[Prefix every line of output with the file or formula name being audited, to make output easy to grep]' \
    '(--only)--except[Specify a comma-separated method list to skip running the methods named `audit_`method]' \
    '(--only-cops --strict --only-cops --only)--except-cops[Specify a comma-separated cops list to skip checking for violations of the listed RuboCop cops]' \
    '--fix[Fix style violations automatically using RuboCop'\''s auto-correct feature]' \
    '--git[Run additional, slower style checks that navigate the Git repository]' \
    '--help[Show this message]' \
    '(--changed --tap)--installed[Only check formulae and casks that are currently installed]' \
    '--new[Run various additional style checks to determine if a new formula or cask is eligible for Homebrew. This should be used when creating new formulae or casks and implies `--strict` and `--online`]' \
    '--online[Run additional, slower style checks that require a network connection]' \
    '(--except --only-cops --except-cops)--only[Specify a comma-separated method list to only run the methods named `audit_`method]' \
    '(--except-cops --strict --except-cops --only)--only-cops[Specify a comma-separated cops list to check for violations of only the listed RuboCop cops]' \
    '--os[Audit the given operating system. (Pass `all` to audit all operating systems.)]' \
    '--quiet[Make some output more quiet]' \
    '--skip-style[Skip running non-RuboCop style checks. Useful if you plan on running `brew style` separately. Enabled by default unless a formula is specified by name]' \
    '(--only-cops --except-cops)--strict[Run additional, stricter style checks]' \
    '(--installed --changed)--tap[Check formulae and casks within the given tap, specified as user`/`repo]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew autoremove
_brew_autoremove() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--dry-run[List what would be uninstalled, but do not actually uninstall anything]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew bottle
_brew_bottle() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--force-core-tap[Build a bottle even if formula is not in `homebrew/core` or any installed taps]' \
    '--help[Show this message]' \
    '--json[Write bottle information to a JSON file, which can be used as the value for `--merge`]' \
    '(--no-rebuild)--keep-old[If the formula specifies a rebuild version, attempt to preserve its value in the generated DSL]' \
    '--merge[Generate an updated bottle block for a formula and optionally merge it into the formula file. Instead of a formula name, requires the path to a JSON file generated with `brew bottle --json` formula]' \
    '--no-all-checks[Don'\''t try to create an `all` bottle or stop a no-change upload]' \
    '--no-commit[When passed with `--write`, a new commit will not generated after writing changes to the formula file]' \
    '(--keep-old)--no-rebuild[If the formula specifies a rebuild version, remove it from the generated DSL]' \
    '--only-json-tab[When passed with `--json`, the tab will be written to the JSON file but not the bottle]' \
    '--quiet[Make some output more quiet]' \
    '--root-url[Use the specified URL as the root of the bottle'\''s URL instead of Homebrew'\''s default]' \
    '--root-url-using[Use the specified download strategy class for downloading the bottle'\''s URL instead of Homebrew'\''s default]' \
    '--skip-relocation[Do not check if the bottle can be marked as relocatable]' \
    '--verbose[Make some output more verbose]' \
    '--write[Write changes to the formula file. A new commit will be generated unless `--no-commit` is passed]' \
    - installed_formula \
    '*:installed_formula:__brew_installed_formulae' \
    - file \
    '*:file:__brew_formulae_or_ruby_files'
}

# brew bump
_brew_bump() {
  _arguments \
    '--bump-synced[Bump additional formulae marked as synced with the given formulae]' \
    '--debug[Display any debugging information]' \
    '--full-name[Print formulae/casks with fully-qualified names]' \
    '--help[Show this message]' \
    '(--tap)--installed[Check formulae and casks that are currently installed]' \
    '(--tap)--no-autobump[Ignore formulae/casks in autobump list (official repositories only)]' \
    '--no-fork[Don'\''t try to fork the repository]' \
    '(--open-pr)--no-pull-requests[Do not retrieve pull requests from GitHub]' \
    '(--no-pull-requests)--open-pr[Open a pull request for the new version if none have been opened yet]' \
    '--quiet[Make some output more quiet]' \
    '--repology[Use Repology to check for outdated packages]' \
    '--start-with[Letter or word that the list of package results should alphabetically follow]' \
    '(--installed --no-autobump)--tap[Check formulae and casks within the given tap, specified as user`/`repo]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask)--formula[Check only formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Check only casks]' \
    '*:cask:__brew_casks'
}

# brew bump-cask-pr
_brew_bump_cask_pr() {
  _arguments \
    '--commit[When passed with `--write-only`, generate a new commit after writing changes to the cask file]' \
    '--debug[Display any debugging information]' \
    '(--write)--dry-run[Print what would be done rather than doing it]' \
    '--fork-org[Use the specified GitHub organization for forking]' \
    '--help[Show this message]' \
    '--message[Prepend message to the default pull request message]' \
    '--no-audit[Don'\''t run `brew audit` before opening the PR]' \
    '--no-browse[Print the pull request URL instead of opening in a browser]' \
    '--no-fork[Don'\''t try to fork the repository]' \
    '--no-style[Don'\''t run `brew style --fix` before opening the PR]' \
    '--quiet[Make some output more quiet]' \
    '--sha256[Specify the SHA-256 checksum of the new download]' \
    '--url[Specify the URL for the new download]' \
    '--verbose[Make some output more verbose]' \
    '(--version-arm --version-intel)--version[Specify the new version for the cask]' \
    '(--version)--version-arm[Specify the new cask version for the ARM architecture]' \
    '(--version)--version-intel[Specify the new cask version for the Intel architecture]' \
    '--write-only[Make the expected file modifications without taking any Git actions]' \
    - cask \
    '*:cask:__brew_casks'
}

# brew bump-compatibility-version
_brew_bump_compatibility_version() {
  _arguments \
    '--debug[Display any debugging information]' \
    '(--write-only)--dry-run[Print what would be done rather than doing it]' \
    '--help[Show this message]' \
    '--message[Append message to the default commit message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '(--dry-run)--write-only[Make the expected file modifications without taking any Git actions]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew bump-formula-pr
_brew_bump_formula_pr() {
  _arguments \
    '--commit[When passed with `--write-only`, generate a new commit after writing changes to the formula file]' \
    '--debug[Display any debugging information]' \
    '(--write-only)--dry-run[Print what would be done rather than doing it]' \
    '--force[Remove all mirrors if `--mirror` was not specified]' \
    '--fork-org[Use the specified GitHub organization for forking]' \
    '--help[Show this message]' \
    '--install-dependencies[Install missing dependencies required to update resources]' \
    '--message[Prepend message to the default pull request message]' \
    '--mirror[Use the specified URL as a mirror URL. If URL is a comma-separated list of URLs, multiple mirrors will be added]' \
    '(--strict --online)--no-audit[Don'\''t run `brew audit` before opening the PR]' \
    '--no-browse[Print the pull request URL instead of opening in a browser]' \
    '--no-fork[Don'\''t try to fork the repository]' \
    '(--no-audit)--online[Run `brew audit --online` before opening the PR]' \
    '--python-exclude-packages[Exclude these Python packages when finding resources]' \
    '--python-extra-packages[Include these additional Python packages when finding resources]' \
    '--python-package-name[Use the specified package-name when finding Python resources for formula. If no package name is specified, it will be inferred from the formula'\''s stable URL]' \
    '--quiet[Make some output more quiet]' \
    '--revision[Specify the new commit revision corresponding to the specified git tag or specified version]' \
    '--sha256[Specify the SHA-256 checksum of the new download]' \
    '(--no-audit)--strict[Run `brew audit --strict` before opening the PR]' \
    '(--url)--tag[Specify the new git commit tag for the formula]' \
    '(--tag)--url[Specify the URL for the new download. If a URL is specified, the SHA-256 checksum of the new download should also be specified]' \
    '--verbose[Make some output more verbose]' \
    '--version[Use the specified version to override the value parsed from the URL or tag. Note that `--version=0` can be used to delete an existing version override from a formula if it has become redundant]' \
    '(--dry-run)--write-only[Make the expected file modifications without taking any Git actions]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew bump-revision
_brew_bump_revision() {
  _arguments \
    '--debug[Display any debugging information]' \
    '(--write-only)--dry-run[Print what would be done rather than doing it]' \
    '--help[Show this message]' \
    '--message[Append message to the default commit message]' \
    '--quiet[Make some output more quiet]' \
    '--remove-bottle-block[Remove the bottle block in addition to bumping the revision]' \
    '--verbose[Make some output more verbose]' \
    '(--dry-run)--write-only[Make the expected file modifications without taking any Git actions]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew bump-unversioned-casks
_brew_bump_unversioned_casks() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--dry-run[Do everything except caching state and opening pull requests]' \
    '--help[Show this message]' \
    '--limit[Maximum runtime in minutes]' \
    '--quiet[Make some output more quiet]' \
    '--state-file[File for caching state]' \
    '--verbose[Make some output more verbose]' \
    - cask \
    '*:cask:__brew_casks' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew bundle
_brew_bundle() {
  local state
  local -a subcommands
  subcommands=(
    'sh:Run your shell in a `brew bundle exec` environment'
    'remove:Remove entries that match `name` from your `Brewfile`. Use `--formula`, `--cask`, `--tap`, `--mas`, `--vscode`, `--go`, `--cargo`, `--uv`, `--flatpak`, `--winget`, `--krew` and `--npm` to remove only entries of the corresponding type. Passing `--formula` also removes matches against formula aliases and old formula names'
    'list:By default, only Homebrew formula dependencies are listed'
    'install:Use this to restore a recorded installed state from a `Brewfile`'
    'upgrade:Use this to restore a recorded installed state from a `Brewfile`'
    'exec:This sanitized build environment ignores unrequested dependencies, which makes sure that things you didn'\''t specify in your `Brewfile` won'\''t get picked up by commands like `bundle install`, `npm install`, etc. It will also add compiler flags which will help with finding keg-only dependencies like `openssl`, `icu4c`, etc'
    'env:Print the environment variables that would be set in a `brew bundle exec` environment'
    'edit:Edit the `Brewfile` in your editor'
    'dump:Write all installed casks/formulae/images/taps into a `Brewfile` in the current directory or to a custom file specified with the `--file` option. This is useful as an installed-state snapshot and can be kept in version control and diffed'
    'cleanup:This workflow is useful for maintainers or testers who regularly install lots of formulae'
    'check:This provides a successful exit code if everything is up-to-date, making it useful for scripting. Use `--verbose` to list unmet dependencies'
    'add:Add entries to your `Brewfile`. Adds formulae by default. Use `--cask`, `--tap`, `--vscode`, `--go`, `--cargo`, `--uv`, `--flatpak`, `--krew` and `--npm` to add the corresponding entry instead'
  )

  _arguments -C \
    '--debug[Display any debugging information]' \
    '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
    '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '1:subcommand:->subcommand' \
    '*::arg:->args'

  case "$state" in
    subcommand)
      _describe -t subcommands 'subcommand' subcommands
      ;;
    args)
      case "$words[1]" in
sh)
        _arguments \
          '--check[Check that all dependencies in the Brewfile are installed before starting the shell. Enabled by default if `$HOMEBREW_BUNDLE_CHECK` is set]' \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '--help[Show this message]' \
          '--install[Run `install` before starting the shell]' \
          '--no-secrets[Attempt to remove secrets from the environment before starting the shell]' \
          '--quiet[Make some output more quiet]' \
          '--services[Temporarily start services while running the shell. Enabled by default if `$HOMEBREW_BUNDLE_SERVICES` is set]' \
          '--verbose[Make some output more verbose]'
        ;;
remove)
        _arguments \
          '(--no-cargo --no-cleanup-cargo --no-dump-cargo)--cargo[Remove entries for Cargo packages]' \
          '(--no-cask --no-casks --no-cleanup-cask --no-dump-cask)--cask[Remove Homebrew cask entries]' \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--no-flatpak --no-cleanup-flatpak --no-dump-flatpak)--flatpak[Remove entries for Flatpak packages. Note: Linux only]' \
          '(--no-formula --no-formulae --no-brews --no-cleanup-brew --no-dump-brew)--formula[Remove Homebrew formula entries, including matches against formula aliases and old names]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '(--no-go --no-cleanup-go --no-dump-go)--go[Remove entries for Go packages]' \
          '--help[Show this message]' \
          '--install[Run `install` before removing entries]' \
          '(--no-krew --no-cleanup-krew --no-dump-krew)--krew[Remove entries for Krew plugins]' \
          '(--no-mas --no-cleanup-mas --no-dump-mas)--mas[Remove entries for Mac App Store dependencies]' \
          '(--no-npm --no-cleanup-npm --no-dump-npm)--npm[Remove entries for npm packages]' \
          '--quiet[Make some output more quiet]' \
          '(--no-tap --no-taps --no-cleanup-tap --no-dump-tap)--tap[Remove Homebrew tap entries]' \
          '(--no-uv --no-cleanup-uv --no-dump-uv)--uv[Remove entries for uv tools]' \
          '--verbose[Make some output more verbose]' \
          '(--no-vscode --no-cleanup-vscode --no-dump-vscode)--vscode[Remove entries for VSCode (and forks/variants) extensions]' \
          '(--no-winget --no-cleanup-winget --no-dump-winget)--winget[Remove entries for WinGet packages. Note: WSL only]'
        ;;
list)
        _arguments \
          '--all[List all dependencies]' \
          '(--no-cargo --no-cleanup-cargo --no-dump-cargo)--cargo[List Cargo packages]' \
          '(--no-cask --no-casks --no-cleanup-cask --no-dump-cask)--cask[List Homebrew cask dependencies]' \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--no-flatpak --no-cleanup-flatpak --no-dump-flatpak)--flatpak[List Flatpak packages. Note: Linux only]' \
          '(--no-formula --no-formulae --no-brews --no-cleanup-brew --no-dump-brew)--formula[List Homebrew formula dependencies]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '(--no-go --no-cleanup-go --no-dump-go)--go[List Go packages]' \
          '--help[Show this message]' \
          '--install[Run `install` before listing dependencies]' \
          '(--no-krew --no-cleanup-krew --no-dump-krew)--krew[List Krew plugins]' \
          '(--no-mas --no-cleanup-mas --no-dump-mas)--mas[List Mac App Store dependencies]' \
          '(--no-npm --no-cleanup-npm --no-dump-npm)--npm[List npm packages]' \
          '--quiet[Make some output more quiet]' \
          '(--no-tap --no-taps --no-cleanup-tap --no-dump-tap)--tap[List Homebrew tap dependencies]' \
          '(--no-uv --no-cleanup-uv --no-dump-uv)--uv[List uv tools]' \
          '--verbose[Make some output more verbose]' \
          '(--no-vscode --no-cleanup-vscode --no-dump-vscode)--vscode[List VSCode (and forks/variants) extensions]' \
          '(--no-winget --no-cleanup-winget --no-dump-winget)--winget[List WinGet packages. Note: WSL only]'
        ;;
install|upgrade)
        _arguments \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '--force[Run with `--force`/`--overwrite`]' \
          '--force-cleanup[Perform cleanup after installing dependencies without asking. Enabled by default if `$HOMEBREW_BUNDLE_FORCE_INSTALL_CLEANUP` is set and `--global` is passed]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '--help[Show this message]' \
          '--jobs[Run up to this many formula installations in parallel. Defaults to 1 (sequential). Use `auto` for the number of CPU cores (max 4)]' \
          '--no-upgrade[Do not run `brew upgrade` on outdated dependencies. Note they may still be upgraded by `brew install` if needed. Enabled by default if `$HOMEBREW_BUNDLE_NO_UPGRADE` is set]' \
          '--quiet[Make some output more quiet]' \
          '--upgrade[Run `brew upgrade` on outdated dependencies, even if `$HOMEBREW_BUNDLE_NO_UPGRADE` is set]' \
          '--upgrade-formulae[Run `brew upgrade` on any of these comma-separated formulae, even if `$HOMEBREW_BUNDLE_NO_UPGRADE` is set]' \
          '--verbose[Print output from commands as they are run]' \
          '--zap[Use `zap` instead of `uninstall` when cleaning up casks after installing dependencies]'
        ;;
exec)
        _arguments \
          '--check[Check that all dependencies in the Brewfile are installed before executing the command. Enabled by default if `$HOMEBREW_BUNDLE_CHECK` is set]' \
          '--debug[Display any debugging information]' \
          '--deny-network[Deny network access from inside the sandbox]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '--help[Show this message]' \
          '--install[Run `install` before executing the command]' \
          '--no-secrets[Attempt to remove secrets from the environment before executing the command]' \
          '--quiet[Make some output more quiet]' \
          '--sandbox[Run command in Homebrew'\''s sandbox, allowing writes to path and Homebrew'\''s temporary and cache directories]' \
          '--services[Temporarily start services while executing the command. Enabled by default if `$HOMEBREW_BUNDLE_SERVICES` is set]' \
          '--verbose[Make some output more verbose]' \
          - command \
          '*:command:__brew_commands'
        ;;
env)
        _arguments \
          '--check[Check that all dependencies in the Brewfile are installed before printing the environment. Enabled by default if `$HOMEBREW_BUNDLE_CHECK` is set]' \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '--help[Show this message]' \
          '--install[Run `install` before printing the environment]' \
          '--no-secrets[Attempt to remove secrets from the environment before printing it]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
edit)
        _arguments \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '--help[Show this message]' \
          '--install[Run `install` before editing the `Brewfile`]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
dump)
        _arguments \
          '(--no-cargo --no-cleanup-cargo --no-dump-cargo)--cargo[Dump Cargo packages]' \
          '(--no-cask --no-casks --no-cleanup-cask --no-dump-cask)--cask[Dump Homebrew cask dependencies]' \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--no-flatpak --no-cleanup-flatpak --no-dump-flatpak)--flatpak[Dump Flatpak packages. Note: Linux only]' \
          '--force[Overwrite an existing `Brewfile`]' \
          '(--no-formula --no-formulae --no-brews --no-cleanup-brew --no-dump-brew)--formula[Dump Homebrew formula dependencies]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '(--no-go --no-cleanup-go --no-dump-go)--go[Dump Go packages]' \
          '--help[Show this message]' \
          '--install[Run `install` before dumping dependencies]' \
          '(--no-krew --no-cleanup-krew --no-dump-krew)--krew[Dump Krew plugins]' \
          '(--no-mas --no-cleanup-mas --no-dump-mas)--mas[Dump Mac App Store dependencies]' \
          '(--cargo)--no-cargo[`dump` without Cargo packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_CARGO` is set]' \
          '(--cask --casks)--no-cask[Dump without Homebrew cask dependencies. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_CASK` is set]' \
          '--no-describe[Do not add description comments above each line. Description comments are the default. Enabled by default if `$HOMEBREW_BUNDLE_NO_DESCRIBE` is set]' \
          '(--formula --formulae --brews)--no-dump-brew[Dump without Homebrew formula dependencies. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_BREW` is set]' \
          '(--cargo)--no-dump-cargo[`dump` without Cargo packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_CARGO` is set]' \
          '(--cask --casks)--no-dump-cask[Dump without Homebrew cask dependencies. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_CASK` is set]' \
          '(--flatpak)--no-dump-flatpak[`dump` without Flatpak packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_FLATPAK` is set]' \
          '(--go)--no-dump-go[`dump` without Go packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_GO` is set]' \
          '(--krew)--no-dump-krew[`dump` without Krew plugins. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_KREW` is set]' \
          '(--mas)--no-dump-mas[`dump` without Mac App Store dependencies. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_MAS` is set]' \
          '(--npm)--no-dump-npm[`dump` without npm packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_NPM` is set]' \
          '(--tap --taps)--no-dump-tap[Dump without Homebrew tap dependencies. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_TAP` is set]' \
          '(--uv)--no-dump-uv[`dump` without uv tools. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_UV` is set]' \
          '(--vscode)--no-dump-vscode[`dump` without VSCode (and forks/variants) extensions. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_VSCODE` is set]' \
          '(--winget)--no-dump-winget[`dump` without WinGet packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_WINGET` is set]' \
          '(--flatpak)--no-flatpak[`dump` without Flatpak packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_FLATPAK` is set]' \
          '(--formula --formulae --brews)--no-formula[Dump without Homebrew formula dependencies. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_BREW` is set]' \
          '(--go)--no-go[`dump` without Go packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_GO` is set]' \
          '(--krew)--no-krew[`dump` without Krew plugins. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_KREW` is set]' \
          '(--mas)--no-mas[`dump` without Mac App Store dependencies. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_MAS` is set]' \
          '(--npm)--no-npm[`dump` without npm packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_NPM` is set]' \
          '--no-restart[Do not add `restart_service` to formula lines]' \
          '(--tap --taps)--no-tap[Dump without Homebrew tap dependencies. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_TAP` is set]' \
          '(--uv)--no-uv[`dump` without uv tools. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_UV` is set]' \
          '(--vscode)--no-vscode[`dump` without VSCode (and forks/variants) extensions. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_VSCODE` is set]' \
          '(--winget)--no-winget[`dump` without WinGet packages. Enabled by default if `$HOMEBREW_BUNDLE_DUMP_NO_WINGET` is set]' \
          '(--no-npm --no-cleanup-npm --no-dump-npm)--npm[Dump npm packages]' \
          '--quiet[Make some output more quiet]' \
          '(--no-tap --no-taps --no-cleanup-tap --no-dump-tap)--tap[Dump Homebrew tap dependencies]' \
          '(--no-uv --no-cleanup-uv --no-dump-uv)--uv[Dump uv tools]' \
          '--verbose[Make some output more verbose]' \
          '(--no-vscode --no-cleanup-vscode --no-dump-vscode)--vscode[Dump VSCode (and forks/variants) extensions]' \
          '(--no-winget --no-cleanup-winget --no-dump-winget)--winget[Dump WinGet packages. Note: WSL only]'
        ;;
cleanup)
        _arguments \
          '--all[Clean up all supported dependencies]' \
          '(--no-cargo --no-cleanup-cargo --no-dump-cargo)--cargo[Clean up Cargo packages]' \
          '(--no-cask --no-casks --no-cleanup-cask --no-dump-cask)--cask[Clean up Homebrew cask dependencies]' \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--no-flatpak --no-cleanup-flatpak --no-dump-flatpak)--flatpak[Clean up Flatpak packages. Note: Linux only]' \
          '--force[Actually perform cleanup operations]' \
          '(--no-formula --no-formulae --no-brews --no-cleanup-brew --no-dump-brew)--formula[Clean up Homebrew formula dependencies]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '(--no-go --no-cleanup-go --no-dump-go)--go[Clean up Go packages]' \
          '--help[Show this message]' \
          '--install[Run `install` before cleaning up dependencies]' \
          '(--no-krew --no-cleanup-krew --no-dump-krew)--krew[Clean up Krew plugins]' \
          '(--no-mas --no-cleanup-mas --no-dump-mas)--mas[Clean up Mac App Store dependencies]' \
          '(--cargo)--no-cargo[`cleanup` without Cargo packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_CARGO` is set]' \
          '(--cask --casks)--no-cask[Clean up without Homebrew cask dependencies. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_CASK` is set]' \
          '(--formula --formulae --brews)--no-cleanup-brew[Clean up without Homebrew formula dependencies. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_BREW` is set]' \
          '(--cargo)--no-cleanup-cargo[`cleanup` without Cargo packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_CARGO` is set]' \
          '(--cask --casks)--no-cleanup-cask[Clean up without Homebrew cask dependencies. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_CASK` is set]' \
          '(--flatpak)--no-cleanup-flatpak[`cleanup` without Flatpak packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_FLATPAK` is set]' \
          '(--go)--no-cleanup-go[`cleanup` without Go packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_GO` is set]' \
          '(--krew)--no-cleanup-krew[`cleanup` without Krew plugins. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_KREW` is set]' \
          '(--mas)--no-cleanup-mas[`cleanup` without Mac App Store dependencies. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_MAS` is set]' \
          '(--npm)--no-cleanup-npm[`cleanup` without npm packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_NPM` is set]' \
          '(--tap --taps)--no-cleanup-tap[Clean up without Homebrew tap dependencies. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_TAP` is set]' \
          '(--uv)--no-cleanup-uv[`cleanup` without uv tools. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_UV` is set]' \
          '(--vscode)--no-cleanup-vscode[`cleanup` without VSCode (and forks/variants) extensions. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_VSCODE` is set]' \
          '(--winget)--no-cleanup-winget[`cleanup` without WinGet packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_WINGET` is set]' \
          '(--flatpak)--no-flatpak[`cleanup` without Flatpak packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_FLATPAK` is set]' \
          '(--formula --formulae --brews)--no-formula[Clean up without Homebrew formula dependencies. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_BREW` is set]' \
          '(--go)--no-go[`cleanup` without Go packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_GO` is set]' \
          '(--krew)--no-krew[`cleanup` without Krew plugins. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_KREW` is set]' \
          '(--mas)--no-mas[`cleanup` without Mac App Store dependencies. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_MAS` is set]' \
          '(--npm)--no-npm[`cleanup` without npm packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_NPM` is set]' \
          '(--tap --taps)--no-tap[Clean up without Homebrew tap dependencies. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_TAP` is set]' \
          '(--uv)--no-uv[`cleanup` without uv tools. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_UV` is set]' \
          '(--vscode)--no-vscode[`cleanup` without VSCode (and forks/variants) extensions. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_VSCODE` is set]' \
          '(--winget)--no-winget[`cleanup` without WinGet packages. Enabled by default if `$HOMEBREW_BUNDLE_CLEANUP_NO_WINGET` is set]' \
          '(--no-npm --no-cleanup-npm --no-dump-npm)--npm[Clean up npm packages]' \
          '--quiet[Make some output more quiet]' \
          '(--no-tap --no-taps --no-cleanup-tap --no-dump-tap)--tap[Clean up Homebrew tap dependencies]' \
          '(--no-uv --no-cleanup-uv --no-dump-uv)--uv[Clean up uv tools]' \
          '--verbose[Make some output more verbose]' \
          '(--no-vscode --no-cleanup-vscode --no-dump-vscode)--vscode[Clean up VSCode (and forks/variants) extensions]' \
          '(--no-winget --no-cleanup-winget --no-dump-winget)--winget[Clean up WinGet packages. Note: WSL only]' \
          '--zap[Clean up casks using the `zap` command instead of `uninstall`]'
        ;;
check)
        _arguments \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '--help[Show this message]' \
          '--install[Run `install` before checking dependencies]' \
          '--no-upgrade[Do not check for outdated dependencies. Note they may still be upgraded by `brew install` if needed. Enabled by default if `$HOMEBREW_BUNDLE_NO_UPGRADE` is set]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[List all missing dependencies]'
        ;;
add)
        _arguments \
          '(--no-cargo --no-cleanup-cargo --no-dump-cargo)--cargo[Add entries for Cargo packages]' \
          '(--no-cask --no-casks --no-cleanup-cask --no-dump-cask)--cask[Add Homebrew cask entries]' \
          '--debug[Display any debugging information]' \
          '(--global)--file[Read from or write to the `Brewfile` from this location. Use `--file=-` to pipe to stdin/stdout]' \
          '(--no-flatpak --no-cleanup-flatpak --no-dump-flatpak)--flatpak[Add entries for Flatpak packages. Note: Linux only]' \
          '(--no-formula --no-formulae --no-brews --no-cleanup-brew --no-dump-brew)--formula[Add Homebrew formula entries]' \
          '(--file)--global[Read from or write to the `Brewfile` from `$HOMEBREW_BUNDLE_FILE_GLOBAL` (if set), `${XDG_CONFIG_HOME}/homebrew/Brewfile` (if `$XDG_CONFIG_HOME` is set), `~/.homebrew/Brewfile` or `~/.Brewfile` otherwise]' \
          '(--no-go --no-cleanup-go --no-dump-go)--go[Add entries for Go packages]' \
          '--help[Show this message]' \
          '--install[Run `install` before adding entries]' \
          '(--no-krew --no-cleanup-krew --no-dump-krew)--krew[Add entries for Krew plugins]' \
          '--no-describe[Do not add description comments above each line. Description comments are the default. Enabled by default if `$HOMEBREW_BUNDLE_NO_DESCRIBE` is set]' \
          '(--no-npm --no-cleanup-npm --no-dump-npm)--npm[Add entries for npm packages]' \
          '--quiet[Make some output more quiet]' \
          '(--no-tap --no-taps --no-cleanup-tap --no-dump-tap)--tap[Add Homebrew tap entries]' \
          '(--no-uv --no-cleanup-uv --no-dump-uv)--uv[Add entries for uv tools]' \
          '--verbose[Make some output more verbose]' \
          '(--no-vscode --no-cleanup-vscode --no-dump-vscode)--vscode[Add entries for VSCode (and forks/variants) extensions]'
        ;;
        *) ;;
      esac
      ;;
  esac
}

# brew casks
_brew_casks() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew cat
_brew_cat() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew cleanup
_brew_cleanup() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--dry-run[Show what would be removed, but do not actually remove anything]' \
    '--help[Show this message]' \
    '--prune[Remove all cache files older than specified days. If you want to remove everything, use `--prune=all`]' \
    '--prune-prefix[Only prune the symlinks and directories from the prefix and remove no other files]' \
    '--quiet[Make some output more quiet]' \
    '--scrub[Scrub the cache, including downloads for even the latest versions. Note that downloads for any installed formulae or casks will still not be deleted. If you want to delete those too: `rm -rf "$(brew --cache)"`]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae' \
    - cask \
    '*:cask:__brew_casks'
}

# brew command
_brew_command() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - command \
    '*:command:__brew_commands'
}

# brew command-not-found-init
_brew_command_not_found_init() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew commands
_brew_commands() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--include-aliases[Include aliases of internal commands]' \
    '--quiet[List only the names of commands without category headers]' \
    '--verbose[Make some output more verbose]'
}

# brew completions
_brew_completions() {
  local state
  local -a subcommands
  subcommands=(
    'unlink:Unlink Homebrew'\''s completions'
    'state:Display the current state of Homebrew'\''s completions'
    'link:Link Homebrew'\''s completions'
  )

  _arguments -C \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '1:subcommand:->subcommand' \
    '*::arg:->args'

  case "$state" in
    subcommand)
      _describe -t subcommands 'subcommand' subcommands
      ;;
    args)
      case "$words[1]" in
unlink)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
state)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
link)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
        *) ;;
      esac
      ;;
  esac
}

# brew config
_brew_config() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew contributions
_brew_contributions() {
  _arguments \
    '--csv[Print a CSV of contributions across repositories over the time period]' \
    '--debug[Display any debugging information]' \
    '--from[Date (ISO 8601 format) to start searching contributions. Omitting this flag searches the past year]' \
    '--help[Show this message]' \
    '(--repositories --team)--organisation[Specify the organisation to populate sources repositories from. Omitting this flag searches the Homebrew primary repositories]' \
    '--quarter[Homebrew contributions quarter to search (1-4). Omitting this flag searches the past year. If `--from` or `--to` are set, they take precedence]' \
    '--quiet[Make some output more quiet]' \
    '(--organisation)--repositories[Specify a comma-separated list of repositories to search. All repositories must be under the same user or organisation. Omitting this flag, or specifying `--repositories=primary`, searches only the main repositories: `Homebrew/brew`, `Homebrew/homebrew-core`, `Homebrew/homebrew-cask`]' \
    '(--organisation --user)--team[Specify the team to populate users from. The first part of the team name will be used as the organisation]' \
    '--to[Date (ISO 8601 format) to stop searching contributions]' \
    '(--team)--user[Specify a comma-separated list of GitHub usernames or email addresses to find contributions from. Omitting this flag searches Homebrew maintainers]' \
    '--verbose[Make some output more verbose]'
}

# brew create
_brew_create() {
  _arguments \
    '(--cask)--HEAD[Indicate that URL points to the package'\''s repository rather than a file]' \
    '(--cabal --cmake --crystal --go --meson --node --perl --python --ruby --rust --zig --cask)--autotools[Create a basic template for an Autotools-style build]' \
    '(--autotools --cmake --crystal --go --meson --node --perl --python --ruby --rust --zig --cask)--cabal[Create a basic template for a Cabal build]' \
    '(--autotools --cabal --cmake --crystal --go --meson --node --perl --python --ruby --rust --zig --HEAD --set-license)--cask[Create a basic template for a cask]' \
    '(--autotools --cabal --crystal --go --meson --node --perl --python --ruby --rust --zig --cask)--cmake[Create a basic template for a CMake-style build]' \
    '(--autotools --cabal --cmake --go --meson --node --perl --python --ruby --rust --zig --cask)--crystal[Create a basic template for a Crystal build]' \
    '--debug[Display any debugging information]' \
    '--force[Ignore errors for disallowed formula names and names that shadow aliases]' \
    '(--autotools --cabal --cmake --crystal --meson --node --perl --python --ruby --rust --zig --cask)--go[Create a basic template for a Go build]' \
    '--help[Show this message]' \
    '(--autotools --cabal --cmake --crystal --go --node --perl --python --ruby --rust --zig --cask)--meson[Create a basic template for a Meson-style build]' \
    '--no-fetch[Homebrew will not download URL to the cache and will thus not add its SHA-256 to the formula for you, nor will it check the GitHub API for GitHub projects (to fill out its description and homepage)]' \
    '(--autotools --cabal --cmake --crystal --go --meson --perl --python --ruby --rust --zig --cask)--node[Create a basic template for a Node build]' \
    '(--autotools --cabal --cmake --crystal --go --meson --node --python --ruby --rust --zig --cask)--perl[Create a basic template for a Perl build]' \
    '(--autotools --cabal --cmake --crystal --go --meson --node --perl --ruby --rust --zig --cask)--python[Create a basic template for a Python build]' \
    '--quiet[Make some output more quiet]' \
    '(--autotools --cabal --cmake --crystal --go --meson --node --perl --python --rust --zig --cask)--ruby[Create a basic template for a Ruby build]' \
    '(--autotools --cabal --cmake --crystal --go --meson --node --perl --python --ruby --zig --cask)--rust[Create a basic template for a Rust build]' \
    '(--cask)--set-license[Explicitly set the license of the new formula]' \
    '--set-name[Explicitly set the name of the new formula or cask]' \
    '--set-version[Explicitly set the version of the new formula or cask]' \
    '--tap[Generate the new formula within the given tap, specified as user`/`repo]' \
    '--verbose[Make some output more verbose]' \
    '(--autotools --cabal --cmake --crystal --go --meson --node --perl --python --ruby --rust --cask)--zig[Create a basic template for a Zig build]'
}

# brew debugger
_brew_debugger() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--open[Start remote debugging over a Unix socket]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - command \
    '*:command:__brew_commands'
}

# brew deps
_brew_deps() {
  _arguments \
    '--HEAD[Show dependencies for HEAD version instead of stable version]' \
    '--annotate[Mark any build, test, implicit, optional, or recommended dependencies as such in the output]' \
    '--arch[Show dependencies for the given CPU architecture]' \
    '--debug[Display any debugging information]' \
    '--direct[Show only the direct dependencies declared in the formula]' \
    '--dot[Show text-based graph description in DOT format]' \
    '--for-each[Switch into the mode used when evaluating all formulae and casks, but only list dependencies for each provided formula, one formula per line]' \
    '--full-name[List dependencies by their full name]' \
    '(--tree)--graph[Show dependencies as a directed graph]' \
    '--help[Show this message]' \
    '--include-build[Include `:build` dependencies for formula]' \
    '--include-implicit[Include implicit dependencies used to download and unpack source files]' \
    '--include-optional[Include `:optional` dependencies for formula]' \
    '--include-requirements[Include requirements in addition to dependencies for formula]' \
    '--include-test[Include `:test` dependencies for formula (non-recursive unless `--graph` or `--tree`)]' \
    '(--missing)--installed[List dependencies for formulae that are currently installed. If formula is specified, list only its dependencies that are currently installed]' \
    '(--installed)--missing[Show only missing dependencies]' \
    '--os[Show dependencies for the given operating system]' \
    '--prune[Prune parts of tree already seen]' \
    '--quiet[Make some output more quiet]' \
    '--skip-recommended[Skip `:recommended` dependencies for formula]' \
    '--topological[Sort dependencies in topological order]' \
    '(--graph)--tree[Show dependencies as a tree. When given multiple formula arguments, show individual trees for each formula]' \
    '--union[Show the union of dependencies for multiple formula, instead of the intersection]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew desc
_brew_desc() {
  _arguments \
    '--debug[Display any debugging information]' \
    '(--search --name)--description[Search just descriptions for text. If text is flanked by slashes, it is interpreted as a regular expression]' \
    '--help[Show this message]' \
    '(--search --description)--name[Search just names for text. If text is flanked by slashes, it is interpreted as a regular expression]' \
    '--quiet[Make some output more quiet]' \
    '(--name --description)--search[Search both names and descriptions for text. If text is flanked by slashes, it is interpreted as a regular expression]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew determine-test-runners
_brew_determine_test_runners() {
  _arguments \
    '(--dependents)--all-supported[Instead of selecting runners based on the chosen formula, return all supported runners]' \
    '--debug[Display any debugging information]' \
    '(--all-supported)--dependents[Determine runners for testing dependents]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew developer
_brew_developer() {
  local state
  local -a subcommands
  subcommands=(
    'state:Display the current state of Homebrew'\''s developer mode'
    'on:Turn Homebrew'\''s developer mode on'
    'off:Turn Homebrew'\''s developer mode off'
  )

  _arguments -C \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '1:subcommand:->subcommand' \
    '*::arg:->args'

  case "$state" in
    subcommand)
      _describe -t subcommands 'subcommand' subcommands
      ;;
    args)
      case "$words[1]" in
state)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
on)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
off)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--verbose[Make some output more verbose]'
        ;;
        *) ;;
      esac
      ;;
  esac
}

# brew dispatch-build-bottle
_brew_dispatch_build_bottle() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--issue[If specified, post a comment to this issue number if the job fails]' \
    '(--linux-self-hosted)--linux[Dispatch bottle for Linux x86_64 (using GitHub runners)]' \
    '--linux-arm64[Dispatch bottle for Linux arm64 (using GitHub runners)]' \
    '(--linux)--linux-self-hosted[Dispatch bottle for Linux x86_64 (using self-hosted runner)]' \
    '--macos[macOS version (or comma-separated list of versions) the bottle should be built for]' \
    '--quiet[Make some output more quiet]' \
    '--tap[Target tap repository (default: `homebrew/core`)]' \
    '--timeout[Build timeout (in minutes, default: 60)]' \
    '--upload[Upload built bottles]' \
    '--verbose[Make some output more verbose]' \
    '--workflow[Dispatch specified workflow (default: `dispatch-build-bottle.yml`)]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew docs
_brew_docs() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew doctor
_brew_doctor() {
  _arguments \
    '--audit-debug[Enable debugging and profiling of audit methods]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--list-checks[List all audit methods, which can be run individually if provided as arguments]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - diagnostic_check \
    '*:diagnostic_check:__brew_diagnostic_checks'
}

# brew edit
_brew_edit() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--print-path[Print the file path to be edited, without opening an editor]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew exec
_brew_exec() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--deny-network[Deny network access from inside the sandbox]' \
    '--formulae[Comma-separated formulae to install and add to `PATH` before running command]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--sandbox[Run command in Homebrew'\''s sandbox, allowing writes to path and Homebrew'\''s temporary and cache directories]' \
    '--verbose[Make some output more verbose]'
}

# brew extract
_brew_extract() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--force[Overwrite the destination formula if it already exists]' \
    '--git-revision[Search for the specified version of formula starting at revision instead of HEAD]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '--version[Extract the specified version of formula instead of the most recent]' \
    - formula \
    '*:formula:__brew_formulae' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew fetch
_brew_fetch() {
  _arguments \
    '(--cask)--HEAD[Fetch HEAD version instead of stable version]' \
    '(--os --arch --bottle-tag)--all-platforms[Download for every supported operating system and architecture, plus each language for casks, fetching each distinct URL once]' \
    '(--bottle-tag --all-platforms)--arch[Download for the given CPU architecture. (Pass `all` to download for all architectures.)]' \
    '(--build-from-source --build-bottle --force-bottle --cask --os --arch --all-platforms)--bottle-tag[Download a bottle for given tag]' \
    '(--build-from-source --force-bottle --bottle-tag --cask)--build-bottle[Download source packages (for eventual bottling) rather than a bottle]' \
    '(--build-bottle --force-bottle --bottle-tag)--build-from-source[Download source packages rather than a bottle]' \
    '--debug[Display any debugging information]' \
    '(--cask)--deps[Also download dependencies for any listed formula]' \
    '--force[Remove a previously cached version and re-fetch]' \
    '(--build-from-source --build-bottle --bottle-tag --cask)--force-bottle[Download a bottle if it exists for the current or newest version of macOS, even if it would not be used during installation]' \
    '--help[Show this message]' \
    '(--bottle-tag --all-platforms)--os[Download for the given operating system. (Pass `all` to download for all operating systems.)]' \
    '--quiet[Make some output more quiet]' \
    '--retry[Retry if downloading fails or re-download if the checksum of a previously cached version no longer matches. Tries at most 5 times with exponential backoff]' \
    '--verbose[Do a verbose VCS checkout, if the URL represents a VCS. This is useful for seeing if an existing VCS cache has been updated]' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--HEAD --deps -s --build-bottle --force-bottle --bottle-tag --formula)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew formula
_brew_formula() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew formula-analytics
_brew_formula_analytics() {
  _arguments \
    '(--json --setup)--all-core-formulae-json[Output a different JSON format containing the JSON data for all Homebrew/homebrew-core formulae]' \
    '(--install --cask-install --install-on-request --build-error --os-version --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-prefixes --homebrew-versions --brew-command-run-options --brew-test-bot-test)--brew-command-run[Output `brew` commands run]' \
    '(--install --cask-install --install-on-request --build-error --os-version --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-prefixes --homebrew-versions --brew-command-run --brew-test-bot-test)--brew-command-run-options[Output `brew` commands run with options]' \
    '(--install --cask-install --install-on-request --build-error --os-version --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-prefixes --homebrew-versions --brew-command-run --brew-command-run-options)--brew-test-bot-test[Output `brew test-bot` steps run]' \
    '(--install --cask-install --install-on-request --os-version --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-prefixes --homebrew-versions --brew-command-run --brew-command-run-options --brew-test-bot-test)--build-error[Output the number of build errors for formulae]' \
    '(--install --install-on-request --build-error --os-version --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-prefixes --homebrew-versions --brew-command-run --brew-command-run-options --brew-test-bot-test)--cask-install[Output the number of installations of casks]' \
    '--days-ago[Query from the specified days ago until the present. The default is 30 days]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '(--install --cask-install --install-on-request --build-error --os-version --homebrew-os-arch-ci --homebrew-prefixes --homebrew-versions --brew-command-run --brew-command-run-options --brew-test-bot-test)--homebrew-devcmdrun-developer[Output the number of devcmdrun/HOMEBREW_DEVELOPER events]' \
    '(--install --cask-install --install-on-request --build-error --os-version --homebrew-devcmdrun-developer --homebrew-prefixes --homebrew-versions --brew-command-run --brew-command-run-options --brew-test-bot-test)--homebrew-os-arch-ci[Output the number of OS/Architecture/CI events]' \
    '(--install --cask-install --install-on-request --build-error --os-version --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-versions --brew-command-run --brew-command-run-options --brew-test-bot-test)--homebrew-prefixes[Output Homebrew prefixes]' \
    '(--install --cask-install --install-on-request --build-error --os-version --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-prefixes --brew-command-run --brew-command-run-options --brew-test-bot-test)--homebrew-versions[Output Homebrew versions]' \
    '(--cask-install --install-on-request --build-error --os-version --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-prefixes --homebrew-versions --brew-command-run --brew-command-run-options --brew-test-bot-test)--install[Output the number of specifically requested installations or installation as dependencies of formulae. This is the default]' \
    '(--install --cask-install --build-error --os-version --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-prefixes --homebrew-versions --brew-command-run --brew-command-run-options --brew-test-bot-test)--install-on-request[Output the number of specifically requested installations of formulae]' \
    '(--all-core-formulae-json --setup)--json[Output JSON. This is required: plain text support has been removed]' \
    '(--install --cask-install --install-on-request --build-error --homebrew-devcmdrun-developer --homebrew-os-arch-ci --homebrew-prefixes --homebrew-versions --brew-command-run --brew-command-run-options --brew-test-bot-test)--os-version[Output the number of events by OS name and version]' \
    '--quiet[Make some output more quiet]' \
    '(--json --all-core-formulae-json)--setup[Install the necessary gems, require them and exit without running a query]' \
    '--verbose[Make some output more verbose]'
}

# brew formulae
_brew_formulae() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew generate-analytics-api
_brew_generate_analytics_api() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew generate-cask-api
_brew_generate_cask_api() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--dry-run[Generate API data without writing it to files]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew generate-cask-ci-matrix
_brew_generate_cask_ci_matrix() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '(--syntax-only)--new[Run new cask checks]' \
    '--quiet[Make some output more quiet]' \
    '(--syntax-only)--skip-install[Skip installing casks]' \
    '(--skip-install --new)--syntax-only[Only run syntax checks]' \
    '(--cask)--url[Treat named argument as a pull request URL]' \
    '--verbose[Make some output more verbose]' \
    - cask \
    '(--url)--cask[Treat all named arguments as cask tokens]' \
    '*:cask:__brew_casks'
}

# brew generate-formula-api
_brew_generate_formula_api() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--dry-run[Generate API data without writing it to files]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew generate-internal-api
_brew_generate_internal_api() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--dry-run[Generate internal API data without writing it to files]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew generate-man-completions
_brew_generate_man_completions() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--no-exit-code[Exit with code 0 even if no changes were made]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew generate-zap
_brew_generate_zap() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--name[Treat the argument as a raw application name instead of a cask token]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew gist-logs
_brew_gist_logs() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--new-issue[Automatically create a new issue in the appropriate GitHub repository after creating the Gist]' \
    '--private[The Gist will be marked private and will not appear in listings but will be accessible with its link]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew home
_brew_home() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew info
_brew_info() {
  _arguments \
    '--analytics[List global Homebrew analytics data or, if specified, installation and build error data for formula (provided neither `$HOMEBREW_NO_ANALYTICS` nor `$HOMEBREW_NO_GITHUB_API` are set)]' \
    '--category[Which type of analytics data to retrieve. The value for category must be `install`, `install-on-request` or `build-error`; `cask-install` or `os-version` may be specified if formula is not. The default is `install`]' \
    '--days[How many days of analytics data to retrieve. The value for days must be `30`, `90` or `365`. The default is `30`]' \
    '--debug[Display any debugging information]' \
    '--github[Open the GitHub source page for formula and cask in a browser. To view the history locally: `brew log -p` formula or cask]' \
    '--help[Show this message]' \
    '--installed[Output a human-readable inventory of installed formulae and casks. If `--json` is passed, print JSON for installed formulae and, with `--json=v2`, installed casks]' \
    '--json[Print a JSON representation. Currently the default value for version is `v1`.`v1` is valid for formula only. `v2` is valid for both formula and cask.See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew]' \
    '--quiet[Make some output more quiet]' \
    '--sizes[Show the size of installed formulae and casks]' \
    '--variations[Include the variations hash in each formula'\''s JSON output]' \
    '--verbose[Show more verbose data for formula, or full information with `--installed`]' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew install
_brew_install() {
  _arguments \
    '(--cask)--HEAD[If formula defines it, install the HEAD version, aka. main, trunk, unstable, master]' \
    '(--formula --force)--adopt[Adopt existing artifacts in the destination that are identical to those being installed. Cannot be combined with `--force`]' \
    '(--formula)--appdir[Target location for Applications (default: `/Applications`)]' \
    '(--formula)--appimagedir[Target location for AppImages (default: `~/Applications`)]' \
    '(--cask)--as-dependency[Install but mark as installed as a dependency and not installed on request]' \
    '(--formula)--audio-unit-plugindir[Target location for Audio Unit Plugins (default: `~/Library/Audio/Plug-Ins/Components`)]' \
    '(--formula)--binaries[Disable/enable linking of helper executables (default: enabled)]' \
    '(--cask)--bottle-arch[Optimise bottles for the specified architecture rather than the oldest architecture supported by the version of macOS the bottles are built on]' \
    '(--cask --build-from-source --force-bottle)--build-bottle[Prepare the formula for eventual bottling during installation, skipping any post-install steps]' \
    '(--cask --build-bottle --force-bottle)--build-from-source[Compile formula from source even if a bottle is provided. Dependencies will still be installed from bottles if they are available]' \
    '(--cask)--cc[Attempt to compile using the specified compiler, which should be the name of the compiler'\''s executable, e.g. `gcc-9` for GCC 9. In order to use LLVM'\''s clang, specify `llvm_clang`. To use the Apple-provided clang, specify `clang`. This option will only accept compilers that are provided by Homebrew or bundled with macOS. Please do not file issues if you encounter errors while using this option]' \
    '(--formula)--colorpickerdir[Target location for Color Pickers (default: `~/Library/ColorPickers`)]' \
    '--debug[If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory]' \
    '(--cask)--debug-symbols[Generate debug symbols on build. Source will be retained in a cache directory]' \
    '(--formula)--dictionarydir[Target location for Dictionaries (default: `~/Library/Dictionaries`)]' \
    '--display-times[Print install times for each package at the end of the run. Enabled by default if `$HOMEBREW_DISPLAY_INSTALL_TIMES` is set]' \
    '--dry-run[Show what would be installed, but do not actually install anything]' \
    '(--cask)--fetch-HEAD[Fetch the upstream repository to detect if the HEAD installation of the formula is outdated. Otherwise, the repository'\''s HEAD will only be checked for updates when a new stable or development version has been released]' \
    '(--formula)--fontdir[Target location for Fonts (default: `~/Library/Fonts`)]' \
    '(--adopt)--force[Install formulae without checking for previously installed keg-only or non-migrated versions. When installing casks, overwrite existing files (binaries and symlinks are excluded, unless originally from the same cask)]' \
    '(--cask --build-from-source --build-bottle)--force-bottle[Install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation]' \
    '(--cask)--git[Create a Git repository, useful for creating patches to the software]' \
    '--help[Show this message]' \
    '(--cask --only-dependencies)--ignore-dependencies[An unsupported Homebrew development option to skip installing any dependencies of any kind. If the dependencies are not already present, the formula will have issues. If you'\''re not developing Homebrew, consider adjusting your PATH rather than using this option]' \
    '(--cask)--include-test[Install testing dependencies required to run `brew test` formula]' \
    '(--formula)--input-methoddir[Target location for Input Methods (default: `~/Library/Input Methods`)]' \
    '(--cask)--interactive[Download and patch formula, then open a shell. This allows the user to run `./configure --help` and otherwise determine how to turn the software package into a Homebrew package]' \
    '(--formula)--internet-plugindir[Target location for Internet Plugins (default: `~/Library/Internet Plug-Ins`)]' \
    '(--cask)--keep-tmp[Retain the temporary files created during installation]' \
    '(--formula)--keyboard-layoutdir[Target location for Keyboard Layouts (default: `/Library/Keyboard Layouts`)]' \
    '(--formula)--language[Comma-separated list of language codes to prefer for cask installation. The first matching language is used, otherwise it reverts to the cask'\''s default language. The default value is the language of your system]' \
    '(--formula)--mdimporterdir[Target location for Spotlight Plugins (default: `~/Library/Spotlight`)]' \
    '--no-ask[Do not ask for confirmation before downloading and installing. Ask mode is the default. Enabled by default if `$HOMEBREW_NO_ASK` is set]' \
    '--no-binaries[Disable/enable linking of helper executables (default: enabled)]' \
    '(--cask --ignore-dependencies)--only-dependencies[Install the dependencies with specified options but do not install the formula itself]' \
    '(--cask)--overwrite[Delete files that already exist in the prefix while linking]' \
    '(--formula)--prefpanedir[Target location for Preference Panes (default: `~/Library/PreferencePanes`)]' \
    '(--formula)--qlplugindir[Target location for Quick Look Plugins (default: `~/Library/QuickLook`)]' \
    '--quiet[Make some output more quiet]' \
    '(--formula)--require-sha[Require all casks to have a checksum]' \
    '(--formula)--screen-saverdir[Target location for Screen Savers (default: `~/Library/Screen Savers`)]' \
    '(--formula)--servicedir[Target location for Services (default: `~/Library/Services`)]' \
    '(--formula)--skip-cask-deps[Skip installing cask dependencies]' \
    '(--cask)--skip-link[Install but skip linking the keg into the prefix]' \
    '(--cask)--skip-post-install[Install but skip any post-install steps]' \
    '--verbose[Print the verification and post-install steps]' \
    '(--formula)--vst-plugindir[Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)]' \
    '(--formula)--vst3-plugindir[Target location for VST3 Plugins (default: `~/Library/Audio/Plug-Ins/VST3`)]' \
    '(--formula)--zap[For use with `brew reinstall --cask`. Remove all files associated with a cask. *May remove files which are shared between applications.*]' \
    - formula \
    '(--casks --binaries --require-sha --adopt --skip-cask-deps --zap --appdir --appimagedir --keyboard-layoutdir --colorpickerdir --prefpanedir --qlplugindir --mdimporterdir --dictionarydir --fontdir --servicedir --input-methoddir --internet-plugindir --audio-unit-plugindir --vst-plugindir --vst3-plugindir --screen-saverdir --language)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formulae --ignore-dependencies --only-dependencies --cc --build-from-source --force-bottle --include-test --HEAD --fetch-HEAD --keep-tmp --debug-symbols --build-bottle --skip-post-install --skip-link --as-dependency --bottle-arch --interactive --git --overwrite)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew install-bundler-gems
_brew_install_bundler_gems() {
  _arguments \
    '(--groups)--add-groups[Installs the specified comma-separated list of gem groups, in addition to those already installed]' \
    '--debug[Display any debugging information]' \
    '(--add-groups)--groups[Installs the specified comma-separated list of gem groups (default: last used). Replaces any previously installed groups]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew irb
_brew_irb() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--examples[Show several examples]' \
    '--help[Show this message]' \
    '--pry[Use Pry instead of IRB. Enabled by default if `$HOMEBREW_PRY` is set]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew leaves
_brew_leaves() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '(--installed-on-request)--installed-as-dependency[Only list leaves that were installed as dependencies]' \
    '(--installed-as-dependency)--installed-on-request[Only list leaves that were manually installed]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew lgtm
_brew_lgtm() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--online[Run additional, slower checks that require a network connection]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew link
_brew_link() {
  _arguments \
    '--HEAD[Link the HEAD version of the formula if it is installed]' \
    '--debug[Display any debugging information]' \
    '--dry-run[List files which would be linked or deleted by `brew link --overwrite` without actually linking or deleting any files]' \
    '--force[Allow keg-only formulae to be linked]' \
    '--help[Show this message]' \
    '--overwrite[Delete files that already exist in the prefix while linking]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - installed_formula \
    '*:installed_formula:__brew_installed_formulae'
}

# brew linkage
_brew_linkage() {
  _arguments \
    '--cached[Print the cached linkage values stored in `$HOMEBREW_CACHE`, set by a previous `brew linkage` run]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--reverse[For every library that a keg references, print its dylib path followed by the binaries that link to it]' \
    '--strict[Exit with a non-zero status if any undeclared dependencies with linkage are found]' \
    '--test[Show only missing libraries and exit with a non-zero status if any missing libraries are found]' \
    '--verbose[Make some output more verbose]' \
    - installed_formula \
    '*:installed_formula:__brew_installed_formulae'
}

# brew list
_brew_list() {
  _arguments \
    '(--cask --versions --multiple --pinned -l)--built-from-source[List the formulae compiled from source]' \
    '--debug[Display any debugging information]' \
    '(--versions --multiple --pinned -l -r -t)--full-name[Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output]' \
    '--help[Show this message]' \
    '(--cask --versions --multiple --pinned -l)--installed-on-request[List the formulae installed on request]' \
    '--json[Output installed formulae and casks with versions, linked and opt-linked formula versions and pinned versions as JSON using the fast Bash command path. Requires `--versions`, no named arguments and `jq`]' \
    '(--cask --pinned --installed-on-request --no-installed-on-request --poured-from-bottle --built-from-source -1 -l -r -t --full-name)--multiple[Only show formulae with multiple versions installed. Implies `--versions`]' \
    '(--cask --versions --multiple --pinned -l)--no-installed-on-request[List the formulae not installed on request (i.e. installed as dependencies)]' \
    '(--multiple --installed-on-request --no-installed-on-request --poured-from-bottle --built-from-source -1 -l -r -t --full-name)--pinned[List only pinned packages, or only the specified (pinned) packages if formula or cask are provided. See also `pin`, `unpin`]' \
    '(--cask --versions --multiple --pinned -l)--poured-from-bottle[List the formulae installed from a bottle]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '(--installed-on-request --no-installed-on-request --poured-from-bottle --built-from-source -1 -l -r -t --full-name)--versions[Show the version number for installed formulae, or only the specified formulae if formula are provided]' \
    '(--versions --multiple --pinned)-1[Force output to be one entry per line. This is the default when output is not to a terminal]' \
    '(--installed-on-request --no-installed-on-request --poured-from-bottle --built-from-source --versions --multiple --pinned --full-name)-l[List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument]' \
    '(--versions --multiple --pinned --full-name)-r[Reverse the order of formula and/or cask sorting to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument]' \
    '(--versions --multiple --pinned --full-name)-t[Sort formulae and/or casks by time modified, listing most recently modified first. Has no effect when a formula or cask name is passed as an argument]' \
    - installed_formula \
    '(--cask)--formula[List only formulae, or treat all named arguments as formulae]' \
    '*:installed_formula:__brew_installed_formulae' \
    - installed_cask \
    '(--formula --multiple --installed-on-request --no-installed-on-request --poured-from-bottle --built-from-source)--cask[List only casks, or treat all named arguments as casks]' \
    '*:installed_cask:__brew_installed_casks'
}

# brew livecheck
_brew_livecheck() {
  _arguments \
    '--autobump[Include packages that are autobumped by BrewTestBot. By default these are skipped]' \
    '(--json)--debug[Display any debugging information]' \
    '(--formula)--extract-plist[Enable checking multiple casks with ExtractPlist strategy]' \
    '--full-name[Print formulae and casks with fully-qualified names]' \
    '--help[Show this message]' \
    '(--tap)--installed[Check formulae and casks that are currently installed]' \
    '(--debug)--json[Output information in JSON format]' \
    '--newer-only[Show the latest version only if it'\''s newer than the current formula or cask version]' \
    '--quiet[Suppress warnings, don'\''t print a progress bar for JSON output]' \
    '--resources[Also check resources for formulae]' \
    '(--installed)--tap[Check formulae and casks within the given tap, specified as user`/`repo]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask --extract-plist)--formula[Only check formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Only check casks]' \
    '*:cask:__brew_casks'
}

# brew log
_brew_log() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '(-1)--max-count[Print only a specified number of commits]' \
    '--oneline[Print only one line per commit]' \
    '--patch[Also print patch from commit]' \
    '--quiet[Make some output more quiet]' \
    '--stat[Also print diffstat from commit]' \
    '--verbose[Make some output more verbose]' \
    '(--max-count)-1[Print only one commit]' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew mcp-server
_brew_mcp_server() {
  _arguments \
    '--debug[Enable debug logging to stderr]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew migrate
_brew_migrate() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--dry-run[Show what would be migrated, but do not actually migrate anything]' \
    '--force[Treat installed formula and provided formula as if they are from the same taps and migrate them anyway]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - installed_formula \
    '(--cask)--formula[Only migrate formulae]' \
    '*:installed_formula:__brew_installed_formulae' \
    - installed_cask \
    '(--formula)--cask[Only migrate casks]' \
    '*:installed_cask:__brew_installed_casks'
}

# brew missing
_brew_missing() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--hide[Act as if none of the specified hidden are installed. hidden should be a comma-separated list of formulae or casks]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae' \
    - cask \
    '*:cask:__brew_casks'
}

# brew nodenv-sync
_brew_nodenv_sync() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew options
_brew_options() {
  _arguments \
    '--compact[Show all options on a single line separated by spaces]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--installed[Show options for formulae that are currently installed]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew outdated
_brew_outdated() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--fetch-HEAD[Fetch the upstream repository to detect if the HEAD installation of the formula is outdated. Otherwise, the repository'\''s HEAD will only be checked for updates when a new stable or development version has been released]' \
    '--greedy[Also include outdated casks with `version :latest` and `auto_updates true` casks that would otherwise be skipped. Enabled by default if `$HOMEBREW_UPGRADE_GREEDY` is set]' \
    '--greedy-auto-updates[Also include outdated `auto_updates true` casks that would otherwise be skipped]' \
    '--greedy-latest[Also include outdated casks including those with `version :latest`]' \
    '--help[Show this message]' \
    '(--quiet --verbose)--json[Print output in JSON format. There are two versions: `v1` and `v2`. `v1` is deprecated and is currently the default if no version is specified. `v2` prints outdated formulae and casks]' \
    '--minimum-version[Only list a named formula or cask with an installed version below the given minimum version]' \
    '(--verbose --json)--quiet[List only the names of outdated kegs (takes precedence over `--verbose`)]' \
    '(--quiet --json)--verbose[Include detailed version information]' \
    - formula \
    '(--cask)--formula[List only outdated formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[List only outdated casks]' \
    '*:cask:__brew_casks'
}

# brew pin
_brew_pin() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - installed_formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:installed_formula:__brew_installed_formulae' \
    - installed_cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:installed_cask:__brew_installed_casks'
}

# brew postinstall
_brew_postinstall() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - installed_formula \
    '*:installed_formula:__brew_installed_formulae'
}

# brew pr-automerge
_brew_pr_automerge() {
  _arguments \
    '--autosquash[Instruct `brew pr-publish` to automatically reformat and reword commits in the pull request to the preferred format]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--ignore-failures[Include pull requests that have failing status checks]' \
    '--publish[Run `brew pr-publish` on matching pull requests]' \
    '--quiet[Make some output more quiet]' \
    '--tap[Target tap repository (default: `homebrew/core`)]' \
    '--verbose[Make some output more verbose]' \
    '--with-label[Pull requests must have this label]' \
    '--without-approval[Pull requests do not require approval to be merged]' \
    '--without-labels[Pull requests must not have these labels (default: `do not merge`, `new formula`, `automerge-skip`, `pre-release`, `CI-published-bottle-commits`)]' \
    '--workflow[Workflow file to use with `brew pr-publish`]'
}

# brew pr-publish
_brew_pr_publish() {
  _arguments \
    '--autosquash[If supported on the target tap, automatically reformat and reword commits to our preferred format]' \
    '--branch[Branch to use the workflow from (default: `main`)]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--large-runner[Run the upload job on a large runner]' \
    '--message[Message to include when autosquashing revision bumps, deletions and rebuilds]' \
    '--quiet[Make some output more quiet]' \
    '--tap[Target tap repository (default: `homebrew/core`)]' \
    '--verbose[Make some output more verbose]' \
    '--workflow[Target workflow filename (default: `publish-commit-bottles.yml`)]'
}

# brew pr-pull
_brew_pr_pull() {
  _arguments \
    '--artifact-pattern[Download artifacts with the specified pattern (default: `bottles{,_*}`)]' \
    '(--clean)--autosquash[Automatically reformat and reword commits in the pull request to our preferred format]' \
    '--branch-okay[Do not warn if pulling to a branch besides the repository default (useful for testing)]' \
    '(--autosquash)--clean[Do not amend the commits from pull requests]' \
    '--debug[Display any debugging information]' \
    '--dry-run[Print what would be done rather than doing it]' \
    '--head-sha[Expected pull request head commit SHA]' \
    '--help[Show this message]' \
    '--ignore-missing-artifacts[Comma-separated list of workflows which can be ignored if they have not been run]' \
    '--keep-old[If the formula specifies a rebuild version, attempt to preserve its value in the generated DSL]' \
    '--message[Message to include when autosquashing revision bumps, deletions and rebuilds]' \
    '--no-cherry-pick[Do not cherry-pick commits from the pull request branch]' \
    '--no-commit[Do not generate a new commit before uploading]' \
    '--no-upload[Download the bottles but don'\''t upload them]' \
    '--quiet[Make some output more quiet]' \
    '--resolve[When a patch fails to apply, leave in progress and allow user to resolve, instead of aborting]' \
    '--retain-bottle-dir[Does not clean up the tmp directory for the bottle so it can be used later]' \
    '--root-url[Use the specified URL as the root of the bottle'\''s URL instead of Homebrew'\''s default]' \
    '--root-url-using[Use the specified download strategy class for downloading the bottle'\''s URL instead of Homebrew'\''s default]' \
    '--tap[Target tap repository (default: `homebrew/core`)]' \
    '--verbose[Make some output more verbose]' \
    '--warn-on-upload-failure[Warn instead of raising an error if the bottle upload fails. Useful for repairing bottle uploads that previously failed]' \
    '--workflows[Retrieve artifacts from the specified workflow (default: `tests.yml`). Can be a comma-separated list to include multiple workflows]'
}

# brew pr-upload
_brew_pr_upload() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--dry-run[Print what would be done rather than doing it]' \
    '--help[Show this message]' \
    '--keep-old[If the formula specifies a rebuild version, attempt to preserve its value in the generated DSL. When using GitHub Packages, this also appends the manifest to the existing list]' \
    '(--upload-only)--no-commit[Do not generate a new commit before uploading]' \
    '--quiet[Make some output more quiet]' \
    '--root-url[Use the specified URL as the root of the bottle'\''s URL instead of Homebrew'\''s default]' \
    '--root-url-using[Use the specified download strategy class for downloading the bottle'\''s URL instead of Homebrew'\''s default]' \
    '(--no-commit)--upload-only[Skip running `brew bottle` before uploading]' \
    '--verbose[Make some output more verbose]' \
    '--warn-on-upload-failure[Warn instead of raising an error if the bottle upload fails. Useful for repairing bottle uploads that previously failed]'
}

# brew prof
_brew_prof() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--stackprof[Use `stackprof` instead of `ruby-prof` (the default)]' \
    '--verbose[Make some output more verbose]' \
    '--vernier[Use `vernier` instead of `ruby-prof` (the default)]' \
    - command \
    '*:command:__brew_commands'
}

# brew pyenv-sync
_brew_pyenv_sync() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew rbenv-sync
_brew_rbenv_sync() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew readall
_brew_readall() {
  _arguments \
    '--aliases[Verify any alias symlinks in each tap]' \
    '--arch[Read using the given CPU architecture. (Pass `all` to simulate all architectures.)]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--no-simulate[Don'\''t simulate other system configurations when checking formulae and casks]' \
    '--os[Read using the given operating system. (Pass `all` to simulate all operating systems.)]' \
    '--quiet[Make some output more quiet]' \
    '--syntax[Syntax-check all of Homebrew'\''s Ruby files (if no tap is passed)]' \
    '--verbose[Make some output more verbose]' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew reinstall
_brew_reinstall() {
  _arguments \
    '(--formula)--adopt[Adopt existing artifacts in the destination that are identical to those being installed. Cannot be combined with `--force`]' \
    '(--formula)--appdir[Target location for Applications (default: `/Applications`)]' \
    '(--formula)--appimagedir[Target location for AppImages (default: `~/Applications`)]' \
    '(--formula)--audio-unit-plugindir[Target location for Audio Unit Plugins (default: `~/Library/Audio/Plug-Ins/Components`)]' \
    '(--formula)--binaries[Disable/enable linking of helper executables (default: enabled)]' \
    '(--cask --force-bottle)--build-from-source[Compile formula from source even if a bottle is available]' \
    '(--formula)--colorpickerdir[Target location for Color Pickers (default: `~/Library/ColorPickers`)]' \
    '--debug[If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory]' \
    '(--cask)--debug-symbols[Generate debug symbols on build. Source will be retained in a cache directory]' \
    '(--formula)--dictionarydir[Target location for Dictionaries (default: `~/Library/Dictionaries`)]' \
    '--display-times[Print install times for each package at the end of the run. Enabled by default if `$HOMEBREW_DISPLAY_INSTALL_TIMES` is set]' \
    '(--formula)--fontdir[Target location for Fonts (default: `~/Library/Fonts`)]' \
    '--force[Install without checking for previously installed keg-only or non-migrated versions]' \
    '(--cask --build-from-source)--force-bottle[Install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation]' \
    '(--cask)--git[Create a Git repository, useful for creating patches to the software]' \
    '--help[Show this message]' \
    '(--formula)--input-methoddir[Target location for Input Methods (default: `~/Library/Input Methods`)]' \
    '(--cask)--interactive[Download and patch formula, then open a shell. This allows the user to run `./configure --help` and otherwise determine how to turn the software package into a Homebrew package]' \
    '(--formula)--internet-plugindir[Target location for Internet Plugins (default: `~/Library/Internet Plug-Ins`)]' \
    '(--cask)--keep-tmp[Retain the temporary files created during installation]' \
    '(--formula)--keyboard-layoutdir[Target location for Keyboard Layouts (default: `/Library/Keyboard Layouts`)]' \
    '(--formula)--language[Comma-separated list of language codes to prefer for cask installation. The first matching language is used, otherwise it reverts to the cask'\''s default language. The default value is the language of your system]' \
    '(--formula)--mdimporterdir[Target location for Spotlight Plugins (default: `~/Library/Spotlight`)]' \
    '--no-ask[Do not ask for confirmation before downloading and reinstalling. Ask mode is the default. Enabled by default if `$HOMEBREW_NO_ASK` is set]' \
    '--no-binaries[Disable/enable linking of helper executables (default: enabled)]' \
    '(--formula)--prefpanedir[Target location for Preference Panes (default: `~/Library/PreferencePanes`)]' \
    '(--formula)--qlplugindir[Target location for Quick Look Plugins (default: `~/Library/QuickLook`)]' \
    '--quiet[Make some output more quiet]' \
    '(--formula)--require-sha[Require all casks to have a checksum]' \
    '(--formula)--screen-saverdir[Target location for Screen Savers (default: `~/Library/Screen Savers`)]' \
    '(--formula)--servicedir[Target location for Services (default: `~/Library/Services`)]' \
    '(--formula)--skip-cask-deps[Skip installing cask dependencies]' \
    '--verbose[Print the verification and post-install steps]' \
    '(--formula)--vst-plugindir[Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)]' \
    '(--formula)--vst3-plugindir[Target location for VST3 Plugins (default: `~/Library/Audio/Plug-Ins/VST3`)]' \
    '(--formula)--zap[For use with `brew reinstall --cask`. Remove all files associated with a cask. *May remove files which are shared between applications.*]' \
    - formula \
    '(--casks --binaries --require-sha --adopt --skip-cask-deps --zap --appdir --appimagedir --keyboard-layoutdir --colorpickerdir --prefpanedir --qlplugindir --mdimporterdir --dictionarydir --fontdir --servicedir --input-methoddir --internet-plugindir --audio-unit-plugindir --vst-plugindir --vst3-plugindir --screen-saverdir --language)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formulae --build-from-source --interactive --force-bottle --keep-tmp --debug-symbols --git)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew release
_brew_release() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--force[Actually create the release and trigger the workflow. Without this, just show what would be done]' \
    '--help[Show this message]' \
    '(--minor)--major[Create a major release]' \
    '(--major)--minor[Create a minor release]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew rubocop
_brew_rubocop() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew ruby
_brew_ruby() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '-e[Execute the given text string as a script]' \
    '-r[Load a library using `require`]' \
    - file \
    '*:file:__brew_formulae_or_ruby_files'
}

# brew rubydoc
_brew_rubydoc() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--only-public[Only generate public API documentation]' \
    '--open[Open generated documentation in a browser]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew sandbox-exec
_brew_sandbox_exec() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--deny-network[Deny network access from inside the sandbox]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew search
_brew_search() {
  _arguments \
    '(--repology --macports --fink --opensuse --fedora --archlinux --debian --ubuntu)--alpine[Search for text in the given database]' \
    '(--alpine --repology --macports --fink --opensuse --fedora --debian --ubuntu)--archlinux[Search for text in the given database]' \
    '--cask[Search for casks]' \
    '(--open)--closed[Search for only closed GitHub pull requests]' \
    '(--alpine --repology --macports --fink --opensuse --fedora --archlinux --ubuntu)--debian[Search for text in the given database]' \
    '--debug[Display any debugging information]' \
    '(--pull-request)--desc[Search for formulae with a description matching text and casks with a name or description matching text]' \
    '(--alpine --repology --macports --fink --opensuse --archlinux --debian --ubuntu)--fedora[Search for text in the given database]' \
    '(--alpine --repology --macports --opensuse --fedora --archlinux --debian --ubuntu)--fink[Search for text in the given database]' \
    '--formula[Search for formulae]' \
    '--help[Show this message]' \
    '(--alpine --repology --fink --opensuse --fedora --archlinux --debian --ubuntu)--macports[Search for text in the given database]' \
    '(--closed)--open[Search for only open GitHub pull requests]' \
    '(--alpine --repology --macports --fink --fedora --archlinux --debian --ubuntu)--opensuse[Search for text in the given database]' \
    '(--desc)--pull-request[Search for GitHub pull requests containing text]' \
    '--quiet[Make some output more quiet]' \
    '(--alpine --macports --fink --opensuse --fedora --archlinux --debian --ubuntu)--repology[Search for text in the given database]' \
    '(--alpine --repology --macports --fink --opensuse --fedora --archlinux --debian)--ubuntu[Search for text in the given database]' \
    '--verbose[Make some output more verbose]'
}

# brew services
_brew_services() {
  local state
  local -a subcommands
  subcommands=(
    'stop:Stop the service formula immediately and unregister it from launching at login (or boot),'
    'unload:Stop the service formula immediately and unregister it from launching at login (or boot),'
    'terminate:Stop the service formula immediately and unregister it from launching at login (or boot),'
    'term:Stop the service formula immediately and unregister it from launching at login (or boot),'
    't:Stop the service formula immediately and unregister it from launching at login (or boot),'
    'u:Stop the service formula immediately and unregister it from launching at login (or boot),'
    'start:Start the service formula immediately and register it to launch at login (or boot)'
    'launch:Start the service formula immediately and register it to launch at login (or boot)'
    'load:Start the service formula immediately and register it to launch at login (or boot)'
    's:Start the service formula immediately and register it to launch at login (or boot)'
    'l:Start the service formula immediately and register it to launch at login (or boot)'
    'run:Run the service formula without registering to launch at login (or boot)'
    'restart:Stop (if necessary) and start the service formula immediately and register it to launch at login (or boot)'
    'relaunch:Stop (if necessary) and start the service formula immediately and register it to launch at login (or boot)'
    'reload:Stop (if necessary) and start the service formula immediately and register it to launch at login (or boot)'
    'r:Stop (if necessary) and start the service formula immediately and register it to launch at login (or boot)'
    'list:List information about all managed services for the current user (or root)'
    'ls:List information about all managed services for the current user (or root)'
    'kill:Stop the service formula immediately but keep it registered to launch at login (or boot)'
    'k:Stop the service formula immediately but keep it registered to launch at login (or boot)'
    'info:List all managed services for the current user (or root)'
    'i:List all managed services for the current user (or root)'
    'cleanup:Remove all unused services'
    'clean:Remove all unused services'
    'cl:Remove all unused services'
    'rm:Remove all unused services'
  )

  _arguments -C \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--sudo-service-user[When run as root on macOS, run the service(s) as this user]' \
    '--verbose[Make some output more verbose]' \
    '1:subcommand:->subcommand' \
    '*::arg:->args'

  case "$state" in
    subcommand)
      _describe -t subcommands 'subcommand' subcommands
      ;;
    args)
      case "$words[1]" in
stop|unload|terminate|term|t|u)
        _arguments \
          '(--file)--all[Stop all services and unregister them from launching at login (or boot), unless `--keep` is specified]' \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--keep[When stopped, don'\''t unregister the service from launching at login (or boot)]' \
          '(--no-wait)--max-wait[Wait at most this many seconds for `stop` to finish stopping a service. Defaults to 60. Set this to zero (0) seconds to wait indefinitely]' \
          '(--max-wait)--no-wait[Don'\''t wait for `stop` to finish stopping the service]' \
          '--quiet[Make some output more quiet]' \
          '--sudo-service-user[When run as root on macOS, run the service(s) as this user]' \
          '--verbose[Make some output more verbose]' \
          - service \
          '*:service:__brew_services'
        ;;
start|launch|load|s|l)
        _arguments \
          '(--file)--all[Start all services and register them to launch at login (or boot)]' \
          '--debug[Display any debugging information]' \
          '(--all)--file[Use the service file from this location to `start` the service]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--sudo-service-user[When run as root on macOS, run the service(s) as this user]' \
          '--verbose[Make some output more verbose]' \
          - service \
          '*:service:__brew_services'
        ;;
run)
        _arguments \
          '(--file)--all[Run all services without registering them to launch at login (or boot)]' \
          '--debug[Display any debugging information]' \
          '(--all)--file[Use the service file from this location to `run` the service]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--sudo-service-user[When run as root on macOS, run the service(s) as this user]' \
          '--verbose[Make some output more verbose]' \
          - service \
          '*:service:__brew_services'
        ;;
restart|relaunch|reload|r)
        _arguments \
          '(--file)--all[Restart all services]' \
          '--debug[Display any debugging information]' \
          '(--all)--file[Use the service file from this location to `start` the service]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--sudo-service-user[When run as root on macOS, run the service(s) as this user]' \
          '--verbose[Make some output more verbose]' \
          - service \
          '*:service:__brew_services'
        ;;
list|ls)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--json[Output as JSON]' \
          '--quiet[Make some output more quiet]' \
          '--sudo-service-user[When run as root on macOS, run the service(s) as this user]' \
          '--verbose[Make some output more verbose]'
        ;;
kill|k)
        _arguments \
          '(--file)--all[Stop all services immediately but keep them registered to launch at login (or boot)]' \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--sudo-service-user[When run as root on macOS, run the service(s) as this user]' \
          '--verbose[Make some output more verbose]' \
          - service \
          '*:service:__brew_services'
        ;;
info|i)
        _arguments \
          '(--file)--all[List all managed services]' \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--json[Output as JSON]' \
          '--quiet[Make some output more quiet]' \
          '--sudo-service-user[When run as root on macOS, run the service(s) as this user]' \
          '--verbose[Make some output more verbose]' \
          - service \
          '*:service:__brew_services'
        ;;
cleanup|clean|cl|rm)
        _arguments \
          '--debug[Display any debugging information]' \
          '--help[Show this message]' \
          '--quiet[Make some output more quiet]' \
          '--sudo-service-user[When run as root on macOS, run the service(s) as this user]' \
          '--verbose[Make some output more verbose]'
        ;;
        *) ;;
      esac
      ;;
  esac
}

# brew setup-ruby
_brew_setup_ruby() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - command \
    '*:command:__brew_commands'
}

# brew setup-sandbox
_brew_setup_sandbox() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew sh
_brew_sh() {
  _arguments \
    '--cmd[Execute commands in a non-interactive shell]' \
    '--debug[Display any debugging information]' \
    '(--ruby)--env[Use the standard `$PATH` instead of superenv'\''s when `std` is passed]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '(--env)--ruby[Set up Homebrew'\''s Ruby environment]' \
    '--verbose[Make some output more verbose]' \
    - file \
    '*:file:__brew_formulae_or_ruby_files'
}

# brew shellenv
_brew_shellenv() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew source
_brew_source() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew style
_brew_style() {
  _arguments \
    '--changed[Check files that were changed from the `main` branch]' \
    '--debug[Display any debugging information]' \
    '(--only-cops)--except-cops[Specify a comma-separated cops list to skip checking for violations of the listed RuboCop cops]' \
    '--fix[Fix style violations automatically using RuboCop'\''s auto-correct feature]' \
    '--help[Show this message]' \
    '(--except-cops)--only-cops[Specify a comma-separated cops list to check for violations of only the listed RuboCop cops]' \
    '--quiet[Make some output more quiet]' \
    '--reset-cache[Reset the RuboCop cache]' \
    '--todo[Add `rubocop:todo` comments for RuboCop violations that remain after auto-correction. Requires `--fix`]' \
    '--verbose[Make some output more verbose]' \
    - file \
    '*:file:__brew_formulae_or_ruby_files' \
    - tap \
    '*:tap:__brew_any_tap' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew tab
_brew_tab() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '(--no-installed-on-request)--installed-on-request[Mark installed_formula or installed_cask as installed on request]' \
    '(--installed-on-request)--no-installed-on-request[Mark installed_formula or installed_cask as not installed on request]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - installed_formula \
    '(--cask)--formula[Only mark formulae]' \
    '*:installed_formula:__brew_installed_formulae' \
    - installed_cask \
    '(--formula)--cask[Only mark casks]' \
    '*:installed_cask:__brew_installed_casks'
}

# brew tap
_brew_tap() {
  _arguments \
    '--custom-remote[Install or change a tap with a custom remote. Useful for mirrors]' \
    '--debug[Display any debugging information]' \
    '--force[Force install core taps even under API mode]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--repair[Add missing symlinks to tap manpages and shell completions. Correct git remote refs for any taps where upstream HEAD branch has been renamed]' \
    '--verbose[Make some output more verbose]' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew tap-info
_brew_tap_info() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--installed[Show information on each installed tap]' \
    '--json[Print a JSON representation of tap. Currently the default and only accepted value for version is `v1`. See the docs for examples of using the JSON output: https://docs.brew.sh/Querying-Brew]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew tap-new
_brew_tap_new() {
  _arguments \
    '--branch[Initialize Git repository and setup GitHub Actions workflows with the specified branch name (default: `main`)]' \
    '--debug[Display any debugging information]' \
    '--github-packages[Upload bottles to GitHub Packages]' \
    '--help[Show this message]' \
    '--no-git[Don'\''t initialize a Git repository for the tap]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew test
_brew_test() {
  _arguments \
    '--HEAD[Test the HEAD version of a formula]' \
    '--debug[Display any debugging information]' \
    '--force[Test formulae even if they are unlinked]' \
    '--help[Show this message]' \
    '--keep-tmp[Retain the temporary files created for the test]' \
    '--quiet[Make some output more quiet]' \
    '--retry[Retry if a testing fails]' \
    '--verbose[Make some output more verbose]' \
    - installed_formula \
    '*:installed_formula:__brew_installed_formulae'
}

# brew test-bot
_brew_test_bot() {
  _arguments \
    '(--only-formulae-detect)--added-formulae[Use these added formulae rather than running the formulae detection steps]' \
    '--build-dependents-from-source[Build dependents from source rather than testing bottles]' \
    '--build-from-source[Build from source rather than building bottles]' \
    '--cleanup[Clean all state from the Homebrew directory. Use with care!]' \
    '--debug[Display any debugging information]' \
    '(--only-formulae-detect)--deleted-formulae[Use these deleted formulae rather than running the formulae detection steps]' \
    '--dry-run[Print what would be done rather than doing it]' \
    '--fail-fast[Immediately exit on a failing step]' \
    '--git-email[Set the Git author/committer email to the given email]' \
    '--git-name[Set the Git author/committer names to the given name]' \
    '--help[Show this message]' \
    '--junit[generate a JUnit XML test results file]' \
    '--keep-old[Run `brew bottle --keep-old` to build new bottles for a single platform]' \
    '--local[Ask Homebrew to write verbose logs under `./logs/` and set `$HOME` to `./home/`]' \
    '--only-bottles-fetch[Only run the bottles fetch steps. This optional post-upload test checks that all the bottles were uploaded correctly. It is not run unless requested and only needs to be run on a single machine. The bottle commit to be tested must be on the tested branch]' \
    '(--only-cleanup-before --only-setup --only-tap-syntax --only-formulae --only-formulae-detect --only-formulae-dependents --skip-setup)--only-cleanup-after[Only run the post-cleanup step. Needs `--cleanup`, except in GitHub Actions]' \
    '(--only-setup --only-tap-syntax --only-formulae --only-formulae-detect --only-formulae-dependents --only-cleanup-after --skip-setup)--only-cleanup-before[Only run the pre-cleanup step. Needs `--cleanup`, except in GitHub Actions]' \
    '(--only-cleanup-before --only-setup --only-tap-syntax --only-formulae-detect --only-formulae-dependents --only-cleanup-after --skip-setup)--only-formulae[Only run the formulae steps]' \
    '(--skip-dependents --only-cleanup-before --only-setup --only-tap-syntax --only-formulae --only-formulae-detect --only-cleanup-after --skip-setup)--only-formulae-dependents[Only run the formulae dependents steps]' \
    '(--testing-formulae --added-formulae --deleted-formulae --only-cleanup-before --only-setup --only-tap-syntax --only-formulae --only-formulae-dependents --only-cleanup-after --skip-setup)--only-formulae-detect[Only run the formulae detection steps]' \
    '--only-json-tab[Run `brew bottle --only-json-tab` to build new bottles that do not contain a tab]' \
    '(--only-cleanup-before --only-tap-syntax --only-formulae --only-formulae-detect --only-formulae-dependents --only-cleanup-after --skip-setup)--only-setup[Only run the local system setup check step]' \
    '(--only-cleanup-before --only-setup --only-formulae --only-formulae-detect --only-formulae-dependents --only-cleanup-after --skip-setup)--only-tap-syntax[Only run the tap syntax check step]' \
    '--publish[Publish the uploaded bottles]' \
    '--quiet[Make some output more quiet]' \
    '--root-url[Use the specified URL as the root of the bottle'\''s URL instead of Homebrew'\''s default]' \
    '--skip-checksum-only-audit[Don'\''t audit checksum-only changes]' \
    '(--only-formulae-dependents)--skip-dependents[Don'\''t test any dependents]' \
    '--skip-livecheck[Don'\''t test livecheck]' \
    '--skip-new[Don'\''t pass `--new` to `brew audit` for new formulae]' \
    '--skip-new-strict[Don'\''t pass `--strict` to `brew audit` for new formulae]' \
    '--skip-online-checks[Don'\''t pass `--online` to `brew audit` and skip `brew livecheck`]' \
    '--skip-relocation[Run `brew bottle --skip-relocation` to build new bottles that don'\''t require relocation]' \
    '--skip-revision-audit[Don'\''t audit the revision]' \
    '(--only-cleanup-before --only-setup --only-tap-syntax --only-formulae --only-formulae-detect --only-formulae-dependents --only-cleanup-after)--skip-setup[Don'\''t check if the local system is set up correctly]' \
    '--skip-stable-version-audit[Don'\''t audit the stable version]' \
    '--skipped-or-failed-formulae[Use these skipped or failed formulae from formulae steps for a formulae dependents step]' \
    '--stable[Only run the tap syntax checks needed on stable brew]' \
    '--tap[Use the Git repository of the given tap. Defaults to the core tap for syntax checking]' \
    '--test-default-formula[Use a default testing formula when not building a tap and no other formulae are specified]' \
    '--tested-formulae[Use these tested formulae from formulae steps for a formulae dependents step]' \
    '(--only-formulae-detect)--testing-formulae[Use these testing formulae rather than running the formulae detection steps]' \
    '--verbose[Print test step output in real time. Has the side effect of passing output as raw bytes instead of re-encoding in UTF-8]'
}

# brew tests
_brew_tests() {
  _arguments \
    '(--only)--changed[Only runs tests on files that were changed from the `main` branch]' \
    '--coverage[Generate code coverage reports]' \
    '--debug[Enable debugging using `ruby/debug`, or surface the standard `odebug` output]' \
    '--fail-fast[Exit early on the first failing test]' \
    '--generic[Run only OS-agnostic tests]' \
    '--help[Show this message]' \
    '--no-parallel[Run tests serially]' \
    '--online[Include tests that use the GitHub API and tests that use any of the taps for official external commands]' \
    '(--changed)--only[Run only `test_script_spec.rb`. Appending `:line_number` will start at a specific line]' \
    '--profile[Output the n slowest tests. When run without `--no-parallel` this will output the slowest tests for each parallel test process]' \
    '--quiet[Make some output more quiet]' \
    '(--stackprof --vernier)--ruby-prof[Use `ruby-prof` to profile tests]' \
    '--seed[Randomise tests with the specified value instead of a random seed]' \
    '(--vernier --ruby-prof)--stackprof[Use `stackprof` to profile tests]' \
    '--verbose[Make some output more verbose]' \
    '(--stackprof --ruby-prof)--vernier[Use `vernier` to profile tests]'
}

# brew trust
_brew_trust() {
  _arguments \
    '(--tap --formula --command)--cask[Trust the named cask]' \
    '(--tap --formula --cask)--command[Trust the named external command]' \
    '--debug[Display any debugging information]' \
    '(--tap --cask --command)--formula[Trust the named formula]' \
    '--help[Show this message]' \
    '--json[Print trusted entries as JSON. A version number is required. The only accepted value for version is `v1`]' \
    '--quiet[Make some output more quiet]' \
    '(--formula --cask --command)--tap[Trust the named tap]' \
    '--verbose[Make some output more verbose]'
}

# brew typecheck
_brew_typecheck() {
  _arguments \
    '--debug[Display any debugging information]' \
    '(--file)--dir[Typecheck all files in a specific directory]' \
    '(--dir)--file[Typecheck a single file]' \
    '(--lsp)--fix[Automatically fix type errors]' \
    '--help[Show this message]' \
    '--ignore[Ignores input files that contain the given string in their paths (relative to the input path passed to Sorbet)]' \
    '(--update --update-all --fix)--lsp[Start the Sorbet LSP server]' \
    '--quiet[Silence all non-critical errors]' \
    '--suggest-typed[Try upgrading `typed` sigils]' \
    '(--lsp)--update[Update RBI files]' \
    '(--lsp)--update-all[Update all RBI files rather than just updated gems]' \
    '--verbose[Make some output more verbose]' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew unalias
_brew_unalias() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew unbottled
_brew_unbottled() {
  _arguments \
    '--debug[Display any debugging information]' \
    '(--total --lost)--dependents[Skip getting analytics data and sort by number of dependents instead]' \
    '--help[Show this message]' \
    '(--dependents --total)--lost[Print the `homebrew/core` commits where bottles were lost in the last week]' \
    '--quiet[Make some output more quiet]' \
    '--tag[Use the specified bottle tag (e.g. `big_sur`) instead of the current OS]' \
    '(--dependents --lost)--total[Print the number of unbottled and total formulae]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew uninstall
_brew_uninstall() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--force[Delete all installed versions of formula. Uninstall even if cask is not installed, overwrite existing files and ignore errors when removing files]' \
    '--help[Show this message]' \
    '--ignore-dependencies[Don'\''t fail uninstall, even if formula is a dependency of any installed formulae]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '(--formula)--zap[Remove all files associated with a cask. *May remove files which are shared between applications.*]' \
    - installed_formula \
    '(--cask --zap)--formula[Treat all named arguments as formulae]' \
    '*:installed_formula:__brew_installed_formulae' \
    - installed_cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:installed_cask:__brew_installed_casks'
}

# brew unlink
_brew_unlink() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--dry-run[List files which would be unlinked without actually unlinking or deleting any files]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - installed_formula \
    '*:installed_formula:__brew_installed_formulae'
}

# brew unpack
_brew_unpack() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--destdir[Create subdirectories in the directory named by path instead]' \
    '--force[Overwrite the destination directory if it already exists]' \
    '(--patch --cask)--git[Initialise a Git repository in the unpacked source. This is useful for creating patches for the software]' \
    '--help[Show this message]' \
    '(--git --cask)--patch[Patches for formula will be applied to the unpacked source]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:formula:__brew_formulae' \
    - cask \
    '(--formula --patch --git)--cask[Treat all named arguments as casks]' \
    '*:cask:__brew_casks'
}

# brew unpin
_brew_unpin() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - installed_formula \
    '(--cask)--formula[Treat all named arguments as formulae]' \
    '*:installed_formula:__brew_installed_formulae' \
    - installed_cask \
    '(--formula)--cask[Treat all named arguments as casks]' \
    '*:installed_cask:__brew_installed_casks'
}

# brew untap
_brew_untap() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--force[Untap even if formulae or casks from this tap are currently installed]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - tap \
    '*:tap:__brew_any_tap'
}

# brew untrust
_brew_untrust() {
  _arguments \
    '(--tap --formula --command)--cask[Untrust the named cask]' \
    '(--tap --formula --cask)--command[Untrust the named external command]' \
    '--debug[Display any debugging information]' \
    '(--tap --cask --command)--formula[Untrust the named formula]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '(--formula --cask --command)--tap[Untrust the named tap]' \
    '--verbose[Make some output more verbose]'
}

# brew update
_brew_update() {
  _arguments \
    '--auto-update[Run on auto-updates (e.g. before `brew install`). Skips some slower steps]' \
    '--debug[Display a trace of all shell commands as they are executed]' \
    '--force[Always do a slower, full update check (even if unnecessary)]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Print the directories checked and `git` operations performed]'
}

# brew update-if-needed
_brew_update_if_needed() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew update-license-data
_brew_update_license_data() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew update-maintainers
_brew_update_maintainers() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew update-perl-resources
_brew_update_perl_resources() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--ignore-errors[Continue processing even if some resources can'\''t be resolved]' \
    '--print-only[Print the updated resource blocks instead of changing formula]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew update-portable-ruby
_brew_update_portable_ruby() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew update-python-resources
_brew_update_python_resources() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--exclude-packages[Exclude these packages when finding resources]' \
    '--extra-packages[Include these additional packages when finding resources]' \
    '--help[Show this message]' \
    '--ignore-errors[Record all discovered resources, even those that can'\''t be resolved successfully. This option is ignored for homebrew/core formulae]' \
    '--ignore-non-pypi-packages[Don'\''t fail if formula is not a PyPI package]' \
    '--install-dependencies[Install missing dependencies required to update resources]' \
    '--package-name[Use the specified package-name when finding resources for formula. If no package name is specified, it will be inferred from the formula'\''s stable URL]' \
    '--print-only[Print the updated resource blocks instead of changing formula]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    '--version[Use the specified version when finding resources for formula. If no version is specified, the current version for formula will be used]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew update-report
_brew_update_report() {
  _arguments \
    '--auto-update[Run in '\''auto-update'\'' mode (faster, less output)]' \
    '--debug[Display any debugging information]' \
    '--force[Treat installed and updated formulae as if they are from the same taps and migrate them anyway]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew update-reset
_brew_update_reset() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew update-sponsors
_brew_update_sponsors() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew update-test
_brew_update_test() {
  _arguments \
    '--before[Use the commit at the specified date as the start commit]' \
    '--commit[Use the specified commit as the start commit]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--keep-tmp[Retain the temporary directory containing the new repository clone]' \
    '--quiet[Make some output more quiet]' \
    '--to-tag[Set `$HOMEBREW_UPDATE_TO_TAG` to test updating between tags]' \
    '--verbose[Make some output more verbose]'
}

# brew upgrade
_brew_upgrade() {
  _arguments \
    '(--formula)--appdir[Target location for Applications (default: `/Applications`)]' \
    '(--formula)--appimagedir[Target location for AppImages (default: `~/Applications`)]' \
    '(--formula)--audio-unit-plugindir[Target location for Audio Unit Plugins (default: `~/Library/Audio/Plug-Ins/Components`)]' \
    '(--formula)--binaries[Disable/enable linking of helper executables (default: enabled)]' \
    '(--cask --force-bottle)--build-from-source[Compile formula from source even if a bottle is available]' \
    '(--formula)--colorpickerdir[Target location for Color Pickers (default: `~/Library/ColorPickers`)]' \
    '--debug[If brewing fails, open an interactive debugging session with access to IRB or a shell inside the temporary build directory]' \
    '(--cask)--debug-symbols[Generate debug symbols on build. Source will be retained in a cache directory]' \
    '(--formula)--dictionarydir[Target location for Dictionaries (default: `~/Library/Dictionaries`)]' \
    '--display-times[Print install times for each package at the end of the run. Enabled by default if `$HOMEBREW_DISPLAY_INSTALL_TIMES` is set]' \
    '--dry-run[Show what would be upgraded, but do not actually upgrade anything]' \
    '(--cask)--fetch-HEAD[Fetch the upstream repository to detect if the HEAD installation of the formula is outdated. Otherwise, the repository'\''s HEAD will only be checked for updates when a new stable or development version has been released]' \
    '(--formula)--fontdir[Target location for Fonts (default: `~/Library/Fonts`)]' \
    '--force[Install formulae without checking for previously installed keg-only or non-migrated versions. When installing casks, overwrite existing files (binaries and symlinks are excluded, unless originally from the same cask)]' \
    '(--cask --build-from-source)--force-bottle[Install from a bottle if it exists for the current or newest version of macOS, even if it would not normally be used for installation]' \
    '(--formula)--greedy[Also include casks with `version :latest` and `auto_updates true` casks that would otherwise be skipped. Enabled by default if `$HOMEBREW_UPGRADE_GREEDY` is set]' \
    '(--formula)--greedy-auto-updates[Also include `auto_updates true` casks that would otherwise be skipped]' \
    '(--formula)--greedy-latest[Also include casks with `version :latest`]' \
    '--help[Show this message]' \
    '(--formula)--input-methoddir[Target location for Input Methods (default: `~/Library/Input Methods`)]' \
    '(--cask)--interactive[Download and patch formula, then open a shell. This allows the user to run `./configure --help` and otherwise determine how to turn the software package into a Homebrew package]' \
    '(--formula)--internet-plugindir[Target location for Internet Plugins (default: `~/Library/Internet Plug-Ins`)]' \
    '(--cask)--keep-tmp[Retain the temporary files created during installation]' \
    '(--formula)--keyboard-layoutdir[Target location for Keyboard Layouts (default: `/Library/Keyboard Layouts`)]' \
    '(--formula)--language[Comma-separated list of language codes to prefer for cask installation. The first matching language is used, otherwise it reverts to the cask'\''s default language. The default value is the language of your system]' \
    '(--formula)--mdimporterdir[Target location for Spotlight Plugins (default: `~/Library/Spotlight`)]' \
    '--minimum-version[Only upgrade a named formula or cask with an installed version below the given minimum version]' \
    '--no-ask[Do not ask for confirmation before downloading and upgrading. Ask mode is the default. Enabled by default if `$HOMEBREW_NO_ASK` is set]' \
    '--no-binaries[Disable/enable linking of helper executables (default: enabled)]' \
    '(--formula)--no-quit[Prevent running cask applications from being quit during upgrade. Enabled by default if `$HOMEBREW_NO_UPGRADE_QUIT_CASKS` is set]' \
    '(--cask)--overwrite[Delete files that already exist in the prefix while linking]' \
    '(--formula)--prefpanedir[Target location for Preference Panes (default: `~/Library/PreferencePanes`)]' \
    '(--formula)--qlplugindir[Target location for Quick Look Plugins (default: `~/Library/QuickLook`)]' \
    '--quiet[Make some output more quiet]' \
    '(--formula)--require-sha[Require all casks to have a checksum]' \
    '(--formula)--screen-saverdir[Target location for Screen Savers (default: `~/Library/Screen Savers`)]' \
    '(--formula)--servicedir[Target location for Services (default: `~/Library/Services`)]' \
    '(--formula)--skip-cask-deps[Skip installing cask dependencies]' \
    '--verbose[Print the verification and post-install steps]' \
    '(--formula)--vst-plugindir[Target location for VST Plugins (default: `~/Library/Audio/Plug-Ins/VST`)]' \
    '(--formula)--vst3-plugindir[Target location for VST3 Plugins (default: `~/Library/Audio/Plug-Ins/VST3`)]' \
    - installed_formula \
    '(--casks --skip-cask-deps --no-quit --greedy --greedy-latest --greedy-auto-updates --binaries --require-sha --appdir --appimagedir --keyboard-layoutdir --colorpickerdir --prefpanedir --qlplugindir --mdimporterdir --dictionarydir --fontdir --servicedir --input-methoddir --internet-plugindir --audio-unit-plugindir --vst-plugindir --vst3-plugindir --screen-saverdir --language)--formula[Treat all named arguments as formulae. If no named arguments are specified, upgrade only outdated formulae]' \
    '*:installed_formula:__brew_installed_formulae' \
    - installed_cask \
    '(--formulae --build-from-source --interactive --force-bottle --fetch-HEAD --keep-tmp --debug-symbols --overwrite)--cask[Treat all named arguments as casks. If no named arguments are specified, upgrade only outdated casks]' \
    '*:installed_cask:__brew_installed_casks'
}

# brew uses
_brew_uses() {
  _arguments \
    '(--formula)--cask[Include only casks]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--include-build[Include formulae that specify formula as a `:build` dependency]' \
    '--include-implicit[Include formulae that have formula as an implicit dependency for downloading and unpacking source files]' \
    '--include-optional[Include formulae that specify formula as an `:optional` dependency]' \
    '--include-test[Include formulae that specify formula as a `:test` dependency]' \
    '(--missing)--installed[Only list formulae and casks that are currently installed]' \
    '(--installed)--missing[Only list formulae and casks that are not currently installed]' \
    '--quiet[Make some output more quiet]' \
    '--recursive[Resolve more than one level of dependencies]' \
    '--skip-recommended[Skip all formulae that specify formula as a `:recommended` dependency]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '(--cask)--formula[Include only formulae]' \
    '*:formula:__brew_formulae'
}

# brew vendor-gems
_brew_vendor_gems() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--no-commit[Do not generate a new commit upon completion]' \
    '--quiet[Make some output more quiet]' \
    '--update[Update the specified list of vendored gems to the latest version]' \
    '--verbose[Make some output more verbose]'
}

# brew vendor-install
_brew_vendor_install() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]'
}

# brew verify
_brew_verify() {
  _arguments \
    '(--bottle-tag)--arch[Download for the given CPU architecture. (Pass `all` to download for all architectures.)]' \
    '(--os --arch)--bottle-tag[Download a bottle for given tag]' \
    '--debug[Display any debugging information]' \
    '--deps[Also download dependencies for any listed formula]' \
    '--force[Remove a previously cached version and re-fetch]' \
    '--help[Show this message]' \
    '--json[Return JSON for the attestation data for each bottle]' \
    '(--bottle-tag)--os[Download for the given operating system. (Pass `all` to download for all operating systems.)]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew version-install
_brew_version_install() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - formula \
    '*:formula:__brew_formulae'
}

# brew which-formula
_brew_which_formula() {
  _arguments \
    '--debug[Display any debugging information]' \
    '--explain[Output explanation of how to get command by installing one of the providing formulae]' \
    '--help[Show this message]' \
    '--quiet[Make some output more quiet]' \
    '--verbose[Make some output more verbose]' \
    - command \
    '*:command:__brew_commands'
}

# brew which-update
_brew_which_update() {
  _arguments \
    '--bottle-json-dir[Use generated bottle JSON files in the given directory to update formula entries]' \
    '--debug[Display any debugging information]' \
    '--help[Show this message]' \
    '--pull-request[Update entries for formula changes in the given pull request number]' \
    '--quiet[Make some output more quiet]' \
    '--removed-formulae-file[Remove database entries for formulae listed in the given file]' \
    '--repository[GitHub repository for `--pull-request` (default: `$GITHUB_REPOSITORY`)]' \
    '--summary-file[Output a summary of the changes to a file]' \
    '--verbose[Make some output more verbose]'
}

# The main completion function
_brew() {
  local curcontext="$curcontext" state state_descr line expl
  local tmp ret=1

  _arguments -C : \
    '(-v)-v[verbose]' \
    '1:command:->command' \
    '*::options:->options' && return 0

  case "$state" in
    command)
      # set default cache policy
      zstyle -s ":completion:${curcontext%:*}:*" cache-policy tmp ||
         zstyle ":completion:${curcontext%:*}:*" cache-policy __brew_completion_caching_policy
      zstyle -s ":completion:${curcontext%:*}:*" use-cache tmp ||
         zstyle ":completion:${curcontext%:*}:*" use-cache true

      __brew_commands && return 0
      ;;
    options)
      local command_or_alias command
      local -A aliases

      # expand alias e.g. ls -> list
      command_or_alias="${line[1]}"
      aliases=($(__brew_list_aliases))
      command="${aliases[$command_or_alias]:-$command_or_alias}"

      # change context to e.g. brew-list
      curcontext="${curcontext%:*}-${command}:${curcontext##*:}"

      # set default cache policy (we repeat this dance because the context
      # service differs from above)
      zstyle -s ":completion:${curcontext%:*}:*" cache-policy tmp ||
         zstyle ":completion:${curcontext%:*}:*" cache-policy __brew_completion_caching_policy
      zstyle -s ":completion:${curcontext%:*}:*" use-cache tmp ||
         zstyle ":completion:${curcontext%:*}:*" use-cache true

      # call completion for named command e.g. _brew_list
      local completion_func="_brew_${command//-/_}"
      _call_function ret "${completion_func}" && return ret

      _message "a completion function is not defined for command or alias: ${command_or_alias}"
      return 1
    ;;
  esac
}

_brew "$@"
