From 5987c5c1d04c682193937531903e12f6838276b2 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 14 Jul 2024 16:18:26 -0400 Subject: [PATCH] Add stub Ruby commands for all Bash commands. This gets us pretty similar (but easier to manage) manpage output but much nicer completions etc. for all these commands. --- Library/Homebrew/abstract_command.rb | 6 + Library/Homebrew/cmd/--repository.rb | 11 +- Library/Homebrew/cmd/--repository.sh | 6 +- Library/Homebrew/cmd/--version.rb | 23 ++++ Library/Homebrew/cmd/--version.sh | 4 +- Library/Homebrew/cmd/casks.rb | 19 +++ Library/Homebrew/cmd/casks.sh | 5 +- Library/Homebrew/cmd/formulae.rb | 17 +++ Library/Homebrew/cmd/formulae.sh | 5 +- Library/Homebrew/cmd/setup-ruby.rb | 21 ++++ Library/Homebrew/cmd/setup-ruby.sh | 7 +- Library/Homebrew/cmd/shellenv.rb | 29 +++++ Library/Homebrew/cmd/shellenv.sh | 11 +- Library/Homebrew/cmd/update-reset.rb | 23 ++++ Library/Homebrew/cmd/update-reset.sh | 6 +- Library/Homebrew/cmd/update.rb | 31 +++++ Library/Homebrew/cmd/update.sh | 12 +- Library/Homebrew/cmd/vendor-install.rb | 23 ++++ Library/Homebrew/cmd/vendor-install.sh | 5 +- Library/Homebrew/dev-cmd/rubocop.rb | 19 +++ Library/Homebrew/dev-cmd/rubocop.sh | 4 +- completions/bash/brew | 155 +++++++++++++++++++++++++ completions/fish/brew.fish | 65 +++++++++++ completions/zsh/_brew | 87 +++++++++++++- docs/Manpage.md | 18 ++- manpages/brew.1 | 16 ++- 26 files changed, 554 insertions(+), 74 deletions(-) create mode 100644 Library/Homebrew/cmd/--version.rb create mode 100644 Library/Homebrew/cmd/casks.rb create mode 100644 Library/Homebrew/cmd/formulae.rb create mode 100644 Library/Homebrew/cmd/setup-ruby.rb create mode 100644 Library/Homebrew/cmd/shellenv.rb create mode 100644 Library/Homebrew/cmd/update-reset.rb create mode 100644 Library/Homebrew/cmd/update.rb create mode 100644 Library/Homebrew/cmd/vendor-install.rb create mode 100644 Library/Homebrew/dev-cmd/rubocop.rb diff --git a/Library/Homebrew/abstract_command.rb b/Library/Homebrew/abstract_command.rb index 23be6cb3dd..46c4e2b0e2 100644 --- a/Library/Homebrew/abstract_command.rb +++ b/Library/Homebrew/abstract_command.rb @@ -32,6 +32,12 @@ module Homebrew .delete_suffix("-cmd") end + sig { void } + def raise_sh_command_error! + raise StandardError, "This command is just here for completions generation. " \ + "It's actually defined in `cmd/#{command_name}` instead." + end + # @return the AbstractCommand subclass associated with the brew CLI command name. sig { params(name: String).returns(T.nilable(T.class_of(AbstractCommand))) } def command(name) = subclasses.find { _1.command_name == name } diff --git a/Library/Homebrew/cmd/--repository.rb b/Library/Homebrew/cmd/--repository.rb index c016f29d50..a42d16fc52 100644 --- a/Library/Homebrew/cmd/--repository.rb +++ b/Library/Homebrew/cmd/--repository.rb @@ -3,9 +3,6 @@ require "abstract_command" -# This Ruby command exists to allow generation of completions for the Bash -# version. -# It is not meant to be run. module Homebrew module Cmd class Repository < AbstractCommand @@ -20,16 +17,10 @@ module Homebrew EOS named_args :tap - - hide_from_man_page! end sig { override.void } - def run - raise StandardError, - "This command is just here for completions generation. " \ - "It's actually defined in `cmd/--repository.sh` instead." - end + def run = raise_sh_command_error! end end end diff --git a/Library/Homebrew/cmd/--repository.sh b/Library/Homebrew/cmd/--repository.sh index bc3a0786fc..255a52ae7e 100644 --- a/Library/Homebrew/cmd/--repository.sh +++ b/Library/Homebrew/cmd/--repository.sh @@ -1,8 +1,4 @@ -#: * `--repository`, `--repo` [ ...] -#: -#: Display where Homebrew's Git repository is located. -#: -#: If `/` are provided, display where tap `/`'s directory is located. +# Documentation defined in Library/Homebrew/cmd/--repository.rb # HOMEBREW_REPOSITORY, HOMEBREW_LIBRARY are set by brew.sh # shellcheck disable=SC2154 diff --git a/Library/Homebrew/cmd/--version.rb b/Library/Homebrew/cmd/--version.rb new file mode 100644 index 0000000000..7cd4770874 --- /dev/null +++ b/Library/Homebrew/cmd/--version.rb @@ -0,0 +1,23 @@ +# typed: strict +# frozen_string_literal: true + +require "abstract_command" + +module Homebrew + module Cmd + class Version < AbstractCommand + sig { override.returns(String) } + def self.command_name = "--version" + + cmd_args do + description <<~EOS + Print the version numbers of Homebrew, Homebrew/homebrew-core and + Homebrew/homebrew-cask (if tapped) to standard output. + EOS + end + + sig { override.void } + def run = raise_sh_command_error! + end + end +end diff --git a/Library/Homebrew/cmd/--version.sh b/Library/Homebrew/cmd/--version.sh index a3c70595df..1b30d0e552 100644 --- a/Library/Homebrew/cmd/--version.sh +++ b/Library/Homebrew/cmd/--version.sh @@ -1,6 +1,4 @@ -#: * `--version`, `-v` -#: -#: Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask (if tapped) to standard output. +# Documentation defined in Library/Homebrew/cmd/--version.rb # HOMEBREW_CORE_REPOSITORY, HOMEBREW_CASK_REPOSITORY, HOMEBREW_VERSION are set by brew.sh # shellcheck disable=SC2154 diff --git a/Library/Homebrew/cmd/casks.rb b/Library/Homebrew/cmd/casks.rb new file mode 100644 index 0000000000..ec9ebafe41 --- /dev/null +++ b/Library/Homebrew/cmd/casks.rb @@ -0,0 +1,19 @@ +# typed: strict +# frozen_string_literal: true + +require "abstract_command" + +# This Ruby command exists to allow generation of completions for the Bash +# version. It is not meant to be run. +module Homebrew + module Cmd + class Casks < AbstractCommand + cmd_args do + description "List all locally installable casks including short names." + end + + sig { override.void } + def run = raise_sh_command_error! + end + end +end diff --git a/Library/Homebrew/cmd/casks.sh b/Library/Homebrew/cmd/casks.sh index 9b5706e401..b9fe0f5729 100644 --- a/Library/Homebrew/cmd/casks.sh +++ b/Library/Homebrew/cmd/casks.sh @@ -1,7 +1,4 @@ -#: * `casks` -#: -#: List all locally installable casks including short names. -#: +# Documentation defined in Library/Homebrew/cmd/casks.rb # HOMEBREW_LIBRARY is set in bin/brew # shellcheck disable=SC2154 diff --git a/Library/Homebrew/cmd/formulae.rb b/Library/Homebrew/cmd/formulae.rb new file mode 100644 index 0000000000..52b3909d5c --- /dev/null +++ b/Library/Homebrew/cmd/formulae.rb @@ -0,0 +1,17 @@ +# typed: strict +# frozen_string_literal: true + +require "abstract_command" + +module Homebrew + module Cmd + class Formulae < AbstractCommand + cmd_args do + description "List all locally installable formulae including short names." + end + + sig { override.void } + def run = raise_sh_command_error! + end + end +end diff --git a/Library/Homebrew/cmd/formulae.sh b/Library/Homebrew/cmd/formulae.sh index 5cba466dde..c218b822fb 100644 --- a/Library/Homebrew/cmd/formulae.sh +++ b/Library/Homebrew/cmd/formulae.sh @@ -1,7 +1,4 @@ -#: * `formulae` -#: -#: List all locally installable formulae including short names. -#: +# Documentation defined in Library/Homebrew/cmd/formulae.rb # HOMEBREW_LIBRARY is set by bin/brew # shellcheck disable=SC2154 diff --git a/Library/Homebrew/cmd/setup-ruby.rb b/Library/Homebrew/cmd/setup-ruby.rb new file mode 100644 index 0000000000..0053439dc0 --- /dev/null +++ b/Library/Homebrew/cmd/setup-ruby.rb @@ -0,0 +1,21 @@ +# typed: strict +# frozen_string_literal: true + +require "abstract_command" + +module Homebrew + module Cmd + class SetupRuby < AbstractCommand + cmd_args do + description <<~EOS + Installs and configures Homebrew's Ruby. If `command` is passed, it will only run Bundler if necessary for that command. + EOS + + named_args :command + end + + sig { override.void } + def run = raise_sh_command_error! + end + end +end diff --git a/Library/Homebrew/cmd/setup-ruby.sh b/Library/Homebrew/cmd/setup-ruby.sh index 42099874f7..1a101cd481 100644 --- a/Library/Homebrew/cmd/setup-ruby.sh +++ b/Library/Homebrew/cmd/setup-ruby.sh @@ -1,9 +1,4 @@ -#: * `setup-ruby [command]` -#: -#: Installs and configures Homebrew's Ruby. -#: If `command` is passed, it will only run Bundler if necessary for that -#: command. -#: +# Documentation defined in Library/Homebrew/cmd/setup-ruby.rb # HOMEBREW_LIBRARY is set by brew.sh # HOMEBREW_BREW_FILE is set by extend/ENV/super.rb diff --git a/Library/Homebrew/cmd/shellenv.rb b/Library/Homebrew/cmd/shellenv.rb new file mode 100644 index 0000000000..c3b9c00e32 --- /dev/null +++ b/Library/Homebrew/cmd/shellenv.rb @@ -0,0 +1,29 @@ +# typed: strict +# frozen_string_literal: true + +require "abstract_command" + +module Homebrew + module Cmd + class Shellenv < AbstractCommand + cmd_args do + description <<~EOS + Valid shells: bash|csh|fish|pwsh|sh|tcsh|zsh + + Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`. + + The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times. + To help guarantee idempotence, this command produces no output when Homebrew's `bin` and `sbin` directories are first and second + respectively in your `PATH`. Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.bash_profile` or + `~/.zprofile` on macOS and `~/.bashrc` or `~/.zshrc` on Linux) with: `eval "$(brew shellenv)"` + + The shell can be specified explicitly with a supported shell name parameter. Unknown shells will output POSIX exports. + EOS + named_args :shell + end + + sig { override.void } + def run = raise_sh_command_error! + end + end +end diff --git a/Library/Homebrew/cmd/shellenv.sh b/Library/Homebrew/cmd/shellenv.sh index ebdcac51b5..3057d452da 100644 --- a/Library/Homebrew/cmd/shellenv.sh +++ b/Library/Homebrew/cmd/shellenv.sh @@ -1,13 +1,4 @@ -#: * `shellenv [bash|csh|fish|pwsh|sh|tcsh|zsh]` -#: -#: Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`. -#: -#: The variables `HOMEBREW_PREFIX`, `HOMEBREW_CELLAR` and `HOMEBREW_REPOSITORY` are also exported to avoid querying them multiple times. -#: To help guarantee idempotence, this command produces no output when Homebrew's `bin` and `sbin` directories are first and second -#: respectively in your `PATH`. Consider adding evaluation of this command's output to your dotfiles (e.g. `~/.bash_profile` or -#: `~/.zprofile` on macOS and `~/.bashrc` or `~/.zshrc` on Linux) with: `eval "$(brew shellenv)"` -#: -#: The shell can be specified explicitly with a supported shell name parameter. Unknown shells will output POSIX exports. +# Documentation defined in Library/Homebrew/cmd/shellenv.rb # HOMEBREW_CELLAR and HOMEBREW_PREFIX are set by extend/ENV/super.rb # HOMEBREW_REPOSITORY is set by bin/brew diff --git a/Library/Homebrew/cmd/update-reset.rb b/Library/Homebrew/cmd/update-reset.rb new file mode 100644 index 0000000000..9b10d6155f --- /dev/null +++ b/Library/Homebrew/cmd/update-reset.rb @@ -0,0 +1,23 @@ +# typed: strict +# frozen_string_literal: true + +require "abstract_command" + +module Homebrew + module Cmd + class UpdateReset < AbstractCommand + cmd_args do + description <<~EOS + Fetch and reset Homebrew and all tap repositories (or any specified ) using `git`(1) to their latest `origin/HEAD`. + + *Note:* this will destroy all your uncommitted or committed changes. + EOS + + named_args :tap + end + + sig { override.void } + def run = raise_sh_command_error! + end + end +end diff --git a/Library/Homebrew/cmd/update-reset.sh b/Library/Homebrew/cmd/update-reset.sh index be92b1e37b..2e7fa628a0 100644 --- a/Library/Homebrew/cmd/update-reset.sh +++ b/Library/Homebrew/cmd/update-reset.sh @@ -1,8 +1,4 @@ -#: * `update-reset` [ ...] -#: -#: Fetch and reset Homebrew and all tap repositories (or any specified ) using `git`(1) to their latest `origin/HEAD`. -#: -#: *Note:* this will destroy all your uncommitted or committed changes. +# Documentation defined in Library/Homebrew/cmd/update-reset.rb # Replaces the function in Library/Homebrew/brew.sh to cache the Git executable to provide # speedup when using Git repeatedly and prevent errors if the shim changes mid-update. diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb new file mode 100644 index 0000000000..fb486425e4 --- /dev/null +++ b/Library/Homebrew/cmd/update.rb @@ -0,0 +1,31 @@ +# typed: strict +# frozen_string_literal: true + +require "abstract_command" + +module Homebrew + module Cmd + class Update < AbstractCommand + cmd_args do + description <<~EOS + Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations. + EOS + switch "--merge", + description: "Use `git merge` to apply updates (rather than `git rebase`)." + switch "--auto-update", + description: "Run on auto-updates (e.g. before `brew install`). Skips some slower steps." + switch "-f", "--force", + description: "Always do a slower, full update check (even if unnecessary)." + switch "-q", "--quiet", + description: "Make some output more quiet." + switch "-v", "--verbose", + description: "Print the directories checked and `git` operations performed." + switch "-d", "--debug", + description: "Display a trace of all shell commands as they are executed." + end + + sig { override.void } + def run = raise_sh_command_error! + end + end +end diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 4a6ad15dfd..e29bacfc1c 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -1,14 +1,4 @@ -#: * `update` [] -#: -#: Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations. -#: -#: --merge Use `git merge` to apply updates (rather than `git rebase`). -#: --auto-update Run on auto-updates (e.g. before `brew install`). Skips some slower steps. -#: -f, --force Always do a slower, full update check (even if unnecessary). -#: -q, --quiet Make some output more quiet. -#: -v, --verbose Print the directories checked and `git` operations performed. -#: -d, --debug Display a trace of all shell commands as they are executed. -#: -h, --help Show this message. +# Documentation defined in Library/Homebrew/cmd/update.rb # HOMEBREW_CURLRC, HOMEBREW_DEVELOPER, HOMEBREW_GIT_EMAIL, HOMEBREW_GIT_NAME # HOMEBREW_UPDATE_CLEANUP, HOMEBREW_UPDATE_TO_TAG are from the user environment diff --git a/Library/Homebrew/cmd/vendor-install.rb b/Library/Homebrew/cmd/vendor-install.rb new file mode 100644 index 0000000000..cf22afb18f --- /dev/null +++ b/Library/Homebrew/cmd/vendor-install.rb @@ -0,0 +1,23 @@ +# typed: strict +# frozen_string_literal: true + +require "abstract_command" + +module Homebrew + module Cmd + class VendorInstall < AbstractCommand + cmd_args do + description <<~EOS + Install Homebrew's portable Ruby. + EOS + + named_args :target + + hide_from_man_page! + end + + sig { override.void } + def run = raise_sh_command_error! + end + end +end diff --git a/Library/Homebrew/cmd/vendor-install.sh b/Library/Homebrew/cmd/vendor-install.sh index 4a47df700c..5a03a01629 100644 --- a/Library/Homebrew/cmd/vendor-install.sh +++ b/Library/Homebrew/cmd/vendor-install.sh @@ -1,7 +1,4 @@ -#: @hide_from_man_page -#: * `vendor-install` [] -#: -#: Install Homebrew's portable Ruby. +# Documentation defined in Library/Homebrew/cmd/vendor-install.rb # HOMEBREW_CURLRC, HOMEBREW_LIBRARY is from the user environment # HOMEBREW_CACHE, HOMEBREW_CURL, HOMEBREW_LINUX, HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION, HOMEBREW_MACOS, diff --git a/Library/Homebrew/dev-cmd/rubocop.rb b/Library/Homebrew/dev-cmd/rubocop.rb new file mode 100644 index 0000000000..1919994708 --- /dev/null +++ b/Library/Homebrew/dev-cmd/rubocop.rb @@ -0,0 +1,19 @@ +# typed: strict +# frozen_string_literal: true + +require "abstract_command" + +module Homebrew + module Cmd + class Rubocop < AbstractCommand + cmd_args do + description <<~EOS + Installs, configures and runs Homebrew's `rubocop`. + EOS + end + + sig { override.void } + def run = raise_sh_command_error! + end + end +end diff --git a/Library/Homebrew/dev-cmd/rubocop.sh b/Library/Homebrew/dev-cmd/rubocop.sh index 6c30ac10a9..11e5946f39 100644 --- a/Library/Homebrew/dev-cmd/rubocop.sh +++ b/Library/Homebrew/dev-cmd/rubocop.sh @@ -1,6 +1,4 @@ -#: * `rubocop` -#: -#: Installs, configures and runs Homebrew's `rubocop`. +# Documentation defined in Library/Homebrew/dev-cmd/rubocop.rb # HOMEBREW_LIBRARY is from the user environment. # HOMEBREW_RUBY_PATH is set by utils/ruby.sh diff --git a/completions/bash/brew b/completions/bash/brew index 531f978423..dd2b50bb31 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -267,6 +267,22 @@ _brew___repository() { __brew_complete_tapped } +_brew___version() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "${cur}" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + *) ;; + esac +} + _brew__s() { local cur="${COMP_WORDS[COMP_CWORD]}" case "${cur}" in @@ -298,6 +314,22 @@ _brew__s() { esac } +_brew__v() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "${cur}" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + *) ;; + esac +} + _brew_abv() { local cur="${COMP_WORDS[COMP_CWORD]}" case "${cur}" in @@ -572,6 +604,22 @@ _brew_bump_unversioned_casks() { __brew_complete_tapped } +_brew_casks() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "${cur}" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + *) ;; + esac +} + _brew_cat() { local cur="${COMP_WORDS[COMP_CWORD]}" case "${cur}" in @@ -1027,6 +1075,22 @@ _brew_formula() { __brew_complete_formulae } +_brew_formulae() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "${cur}" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + *) ;; + esac +} + _brew_generate_cask_api() { local cur="${COMP_WORDS[COMP_CWORD]}" case "${cur}" in @@ -1997,6 +2061,22 @@ _brew_rm() { __brew_complete_installed_casks } +_brew_rubocop() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "${cur}" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + *) ;; + esac +} + _brew_ruby() { local cur="${COMP_WORDS[COMP_CWORD]}" case "${cur}" in @@ -2065,6 +2145,23 @@ _brew_search() { esac } +_brew_setup_ruby() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "${cur}" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + *) ;; + esac + __brew_complete_commands +} + _brew_sh() { local cur="${COMP_WORDS[COMP_CWORD]}" case "${cur}" in @@ -2084,6 +2181,22 @@ _brew_sh() { __brew_complete_files } +_brew_shellenv() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "${cur}" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + *) ;; + esac +} + _brew_style() { local cur="${COMP_WORDS[COMP_CWORD]}" case "${cur}" in @@ -2539,6 +2652,23 @@ _brew_update_report() { esac } +_brew_update_reset() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "${cur}" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + *) ;; + esac + __brew_complete_tapped +} + _brew_update_sponsors() { local cur="${COMP_WORDS[COMP_CWORD]}" case "${cur}" in @@ -2675,6 +2805,22 @@ _brew_vendor_gems() { esac } +_brew_vendor_install() { + local cur="${COMP_WORDS[COMP_CWORD]}" + case "${cur}" in + -*) + __brewcomp " + --debug + --help + --quiet + --verbose + " + return + ;; + *) ;; + esac +} + _brew() { local i=1 cmd @@ -2713,7 +2859,9 @@ _brew() { --prefix) _brew___prefix ;; --repo) _brew___repo ;; --repository) _brew___repository ;; + --version) _brew___version ;; -S) _brew__s ;; + -v) _brew__v ;; abv) _brew_abv ;; analytics) _brew_analytics ;; audit) _brew_audit ;; @@ -2724,6 +2872,7 @@ _brew() { bump-formula-pr) _brew_bump_formula_pr ;; bump-revision) _brew_bump_revision ;; bump-unversioned-casks) _brew_bump_unversioned_casks ;; + casks) _brew_casks ;; cat) _brew_cat ;; cleanup) _brew_cleanup ;; command) _brew_command ;; @@ -2745,6 +2894,7 @@ _brew() { extract) _brew_extract ;; fetch) _brew_fetch ;; formula) _brew_formula ;; + formulae) _brew_formulae ;; generate-cask-api) _brew_generate_cask_api ;; generate-formula-api) _brew_generate_formula_api ;; generate-man-completions) _brew_generate_man_completions ;; @@ -2785,10 +2935,13 @@ _brew() { release) _brew_release ;; remove) _brew_remove ;; rm) _brew_rm ;; + rubocop) _brew_rubocop ;; ruby) _brew_ruby ;; rubydoc) _brew_rubydoc ;; search) _brew_search ;; + setup-ruby) _brew_setup_ruby ;; sh) _brew_sh ;; + shellenv) _brew_shellenv ;; style) _brew_style ;; tab) _brew_tab ;; tap) _brew_tap ;; @@ -2811,11 +2964,13 @@ _brew() { update-maintainers) _brew_update_maintainers ;; update-python-resources) _brew_update_python_resources ;; update-report) _brew_update_report ;; + update-reset) _brew_update_reset ;; update-sponsors) _brew_update_sponsors ;; update-test) _brew_update_test ;; upgrade) _brew_upgrade ;; uses) _brew_uses ;; vendor-gems) _brew_vendor_gems ;; + vendor-install) _brew_vendor_install ;; *) ;; esac } diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index e0dbc08de5..e951b3325e 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -263,6 +263,13 @@ __fish_brew_complete_arg '--repository' -l verbose -d 'Make some output more ver __fish_brew_complete_arg '--repository' -a '(__fish_brew_suggest_taps_installed)' +__fish_brew_complete_cmd '--version' 'Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask (if tapped) to standard output' +__fish_brew_complete_arg '--version' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg '--version' -l help -d 'Show this message' +__fish_brew_complete_arg '--version' -l quiet -d 'Make some output more quiet' +__fish_brew_complete_arg '--version' -l verbose -d 'Make some output more verbose' + + __fish_brew_complete_cmd '-S' 'Perform a substring search of cask tokens and formula names for text' __fish_brew_complete_arg '-S' -l archlinux -d 'Search for text in the given database' __fish_brew_complete_arg '-S' -l cask -d 'Search for casks' @@ -285,6 +292,13 @@ __fish_brew_complete_arg '-S' -l ubuntu -d 'Search for text in the given databas __fish_brew_complete_arg '-S' -l verbose -d 'Make some output more verbose' +__fish_brew_complete_cmd '-v' 'Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask (if tapped) to standard output' +__fish_brew_complete_arg '-v' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg '-v' -l help -d 'Show this message' +__fish_brew_complete_arg '-v' -l quiet -d 'Make some output more quiet' +__fish_brew_complete_arg '-v' -l verbose -d 'Make some output more verbose' + + __fish_brew_complete_cmd 'abv' 'Display brief statistics for your Homebrew installation' __fish_brew_complete_arg 'abv' -l analytics -d '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)' __fish_brew_complete_arg 'abv' -l cask -d 'Treat all named arguments as casks' @@ -471,6 +485,13 @@ __fish_brew_complete_arg 'bump-unversioned-casks' -a '(__fish_brew_suggest_casks __fish_brew_complete_arg 'bump-unversioned-casks' -a '(__fish_brew_suggest_taps_installed)' +__fish_brew_complete_cmd 'casks' 'List all locally installable casks including short names' +__fish_brew_complete_arg 'casks' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg 'casks' -l help -d 'Show this message' +__fish_brew_complete_arg 'casks' -l quiet -d 'Make some output more quiet' +__fish_brew_complete_arg 'casks' -l verbose -d 'Make some output more verbose' + + __fish_brew_complete_cmd 'cat' 'Display the source of a formula or cask' __fish_brew_complete_arg 'cat' -l cask -d 'Treat all named arguments as casks' __fish_brew_complete_arg 'cat' -l debug -d 'Display any debugging information' @@ -741,6 +762,13 @@ __fish_brew_complete_arg 'formula' -l verbose -d 'Make some output more verbose' __fish_brew_complete_arg 'formula' -a '(__fish_brew_suggest_formulae_all)' +__fish_brew_complete_cmd 'formulae' 'List all locally installable formulae including short names' +__fish_brew_complete_arg 'formulae' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg 'formulae' -l help -d 'Show this message' +__fish_brew_complete_arg 'formulae' -l quiet -d 'Make some output more quiet' +__fish_brew_complete_arg 'formulae' -l verbose -d 'Make some output more verbose' + + __fish_brew_complete_cmd 'generate-cask-api' 'Generate `homebrew/cask` API data files for https://formulae.brew.sh' __fish_brew_complete_arg 'generate-cask-api' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'generate-cask-api' -l dry-run -d 'Generate API data without writing it to files' @@ -1351,6 +1379,13 @@ __fish_brew_complete_arg 'rm; and not __fish_seen_argument -l cask -l casks' -a __fish_brew_complete_arg 'rm; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_installed)' +__fish_brew_complete_cmd 'rubocop' 'Installs, configures and runs Homebrew\'s `rubocop`' +__fish_brew_complete_arg 'rubocop' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg 'rubocop' -l help -d 'Show this message' +__fish_brew_complete_arg 'rubocop' -l quiet -d 'Make some output more quiet' +__fish_brew_complete_arg 'rubocop' -l verbose -d 'Make some output more verbose' + + __fish_brew_complete_cmd 'ruby' 'Run a Ruby instance with Homebrew\'s libraries loaded' __fish_brew_complete_arg 'ruby' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'ruby' -l help -d 'Show this message' @@ -1391,6 +1426,14 @@ __fish_brew_complete_arg 'search' -l ubuntu -d 'Search for text in the given dat __fish_brew_complete_arg 'search' -l verbose -d 'Make some output more verbose' +__fish_brew_complete_cmd 'setup-ruby' 'Installs and configures Homebrew\'s Ruby' +__fish_brew_complete_arg 'setup-ruby' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg 'setup-ruby' -l help -d 'Show this message' +__fish_brew_complete_arg 'setup-ruby' -l quiet -d 'Make some output more quiet' +__fish_brew_complete_arg 'setup-ruby' -l verbose -d 'Make some output more verbose' +__fish_brew_complete_arg 'setup-ruby' -a '(__fish_brew_suggest_commands)' + + __fish_brew_complete_cmd 'sh' 'Enter an interactive shell for Homebrew\'s build environment' __fish_brew_complete_arg 'sh' -l cmd -d 'Execute commands in a non-interactive shell' __fish_brew_complete_arg 'sh' -l debug -d 'Display any debugging information' @@ -1400,6 +1443,13 @@ __fish_brew_complete_arg 'sh' -l quiet -d 'Make some output more quiet' __fish_brew_complete_arg 'sh' -l verbose -d 'Make some output more verbose' +__fish_brew_complete_cmd 'shellenv' 'Valid shells: bash|csh|fish|pwsh|sh|tcsh|zsh Print export statements' +__fish_brew_complete_arg 'shellenv' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg 'shellenv' -l help -d 'Show this message' +__fish_brew_complete_arg 'shellenv' -l quiet -d 'Make some output more quiet' +__fish_brew_complete_arg 'shellenv' -l verbose -d 'Make some output more verbose' + + __fish_brew_complete_cmd 'style' 'Check formulae or files for conformance to Homebrew style guidelines' __fish_brew_complete_arg 'style' -l cask -d 'Treat all named arguments as casks' __fish_brew_complete_arg 'style' -l debug -d 'Display any debugging information' @@ -1656,6 +1706,14 @@ __fish_brew_complete_arg 'update-report' -l quiet -d 'Make some output more quie __fish_brew_complete_arg 'update-report' -l verbose -d 'Make some output more verbose' +__fish_brew_complete_cmd 'update-reset' 'Fetch and reset Homebrew and all tap repositories (or any specified repository) using `git`(1) to their latest `origin/HEAD`' +__fish_brew_complete_arg 'update-reset' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg 'update-reset' -l help -d 'Show this message' +__fish_brew_complete_arg 'update-reset' -l quiet -d 'Make some output more quiet' +__fish_brew_complete_arg 'update-reset' -l verbose -d 'Make some output more verbose' +__fish_brew_complete_arg 'update-reset' -a '(__fish_brew_suggest_taps_installed)' + + __fish_brew_complete_cmd 'update-sponsors' 'Update the list of GitHub Sponsors in the `Homebrew/brew` README' __fish_brew_complete_arg 'update-sponsors' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'update-sponsors' -l help -d 'Show this message' @@ -1747,6 +1805,13 @@ __fish_brew_complete_arg 'vendor-gems' -l update -d 'Update the specified list o __fish_brew_complete_arg 'vendor-gems' -l verbose -d 'Make some output more verbose' +__fish_brew_complete_cmd 'vendor-install' 'Install Homebrew\'s portable Ruby' +__fish_brew_complete_arg 'vendor-install' -l debug -d 'Display any debugging information' +__fish_brew_complete_arg 'vendor-install' -l help -d 'Show this message' +__fish_brew_complete_arg 'vendor-install' -l quiet -d 'Make some output more quiet' +__fish_brew_complete_arg 'vendor-install' -l verbose -d 'Make some output more verbose' + + ################################ ## OFFICIAL EXTERNAL COMMANDS ## diff --git a/completions/zsh/_brew b/completions/zsh/_brew index e66049dbe7..ba5b8eabce 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -208,7 +208,7 @@ __brew_internal_commands() { 'search:Perform a substring search of cask tokens and formula names for text' 'setup-ruby:Installs and configures Homebrew'\''s Ruby' 'sh:Enter an interactive shell for Homebrew'\''s build environment' - 'shellenv:Print export statements' + 'shellenv:Valid shells: bash|csh|fish|pwsh|sh|tcsh|zsh Print export statements' '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' @@ -363,6 +363,15 @@ _brew___repository() { '*::tap:__brew_any_tap' } +# 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 -S _brew__s() { _arguments \ @@ -387,6 +396,15 @@ _brew__s() { '--verbose[Make some output more verbose]' } +# brew -v +_brew__v() { + _arguments \ + '--debug[Display any debugging information]' \ + '--help[Show this message]' \ + '--quiet[Make some output more quiet]' \ + '--verbose[Make some output more verbose]' +} + # brew abv _brew_abv() { _arguments \ @@ -605,6 +623,15 @@ _brew_bump_unversioned_casks() { '*::tap:__brew_any_tap' } +# 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 \ @@ -936,6 +963,15 @@ _brew_formula() { '*::formula:__brew_formulae' } +# 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-cask-api _brew_generate_cask_api() { _arguments \ @@ -1667,6 +1703,15 @@ _brew_rm() { '*::installed_cask:__brew_installed_casks' } +# 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 \ @@ -1715,6 +1760,17 @@ _brew_search() { '--verbose[Make some output more verbose]' } +# 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 sh _brew_sh() { _arguments \ @@ -1728,6 +1784,15 @@ _brew_sh() { '*::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 style _brew_style() { _arguments \ @@ -2049,6 +2114,17 @@ _brew_update_report() { '--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]' \ + - tap \ + '*::tap:__brew_any_tap' +} + # brew update-sponsors _brew_update_sponsors() { _arguments \ @@ -2153,6 +2229,15 @@ _brew_vendor_gems() { '--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]' +} + # The main completion function _brew() { local curcontext="$curcontext" state state_descr line expl diff --git a/docs/Manpage.md b/docs/Manpage.md index f5c7c5a2ea..c73625fbac 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1141,12 +1141,14 @@ Perform a substring search of cask tokens and formula names for *`text`*. If : Search for *`text`* in the given database. -### `setup-ruby [command]` +### `setup-ruby` \[*`command`* ...\] Installs and configures Homebrew's Ruby. If `command` is passed, it will only run Bundler if necessary for that command. -### `shellenv [bash|csh|fish|pwsh|sh|tcsh|zsh]` +### `shellenv` \[*`shell`* ...\] + +Valid shells: bash\|csh\|fish\|pwsh\|sh\|tcsh\|zsh Print export statements. When run in a shell, this installation of Homebrew will be added to your `PATH`, `MANPATH`, and `INFOPATH`. @@ -1284,7 +1286,7 @@ Remove a tapped formula repository. : Untap even if formulae or casks from this tap are currently installed. -### `update` \[*`options`*\] +### `update`, `up` \[*`options`*\] Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations. @@ -1301,7 +1303,15 @@ and perform any necessary migrations. : Always do a slower, full update check (even if unnecessary). -### `update-reset` \[*`path-to-tap-repository`* ...\] +`-v`, `--verbose` + +: Print the directories checked and `git` operations performed. + +`-d`, `--debug` + +: Display a trace of all shell commands as they are executed. + +### `update-reset` \[*`tap`* ...\] Fetch and reset Homebrew and all tap repositories (or any specified *`repository`*) using `git`(1) to their latest `origin/HEAD`. diff --git a/manpages/brew.1 b/manpages/brew.1 index 762e53cb76..66eb7dc5cf 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -719,9 +719,11 @@ Search for \fItext\fP in the given database\. .TP \fB\-\-ubuntu\fP Search for \fItext\fP in the given database\. -.SS "\fBsetup\-ruby \fR[command]\fP" +.SS "\fBsetup\-ruby\fP \fR[\fIcommand\fP \.\.\.]" Installs and configures Homebrew\[u2019]s Ruby\. If \fBcommand\fP is passed, it will only run Bundler if necessary for that command\. -.SS "\fBshellenv \fR[bash|csh|fish|pwsh|sh|tcsh|zsh]\fP" +.SS "\fBshellenv\fP \fR[\fIshell\fP \.\.\.]" +Valid shells: bash|csh|fish|pwsh|sh|tcsh|zsh +.P Print export statements\. When run in a shell, this installation of Homebrew will be added to your \fBPATH\fP, \fBMANPATH\fP, and \fBINFOPATH\fP\&\. .P The variables \fBHOMEBREW_PREFIX\fP, \fBHOMEBREW_CELLAR\fP and \fBHOMEBREW_REPOSITORY\fP are also exported to avoid querying them multiple times\. To help guarantee idempotence, this command produces no output when Homebrew\[u2019]s \fBbin\fP and \fBsbin\fP directories are first and second respectively in your \fBPATH\fP\&\. Consider adding evaluation of this command\[u2019]s output to your dotfiles (e\.g\. \fB~/\.bash_profile\fP or \fB~/\.zprofile\fP on macOS and \fB~/\.bashrc\fP or \fB~/\.zshrc\fP on Linux) with: \fBeval "$(brew shellenv)"\fP @@ -800,7 +802,7 @@ Remove a tapped formula repository\. .TP \fB\-f\fP, \fB\-\-force\fP Untap even if formulae or casks from this tap are currently installed\. -.SS "\fBupdate\fP \fR[\fIoptions\fP]" +.SS "\fBupdate\fP, \fBup\fP \fR[\fIoptions\fP]" Fetch the newest version of Homebrew and all formulae from GitHub using \fBgit\fP(1) and perform any necessary migrations\. .TP \fB\-\-merge\fP @@ -811,7 +813,13 @@ Run on auto\-updates (e\.g\. before \fBbrew install\fP)\. Skips some slower step .TP \fB\-f\fP, \fB\-\-force\fP Always do a slower, full update check (even if unnecessary)\. -.SS "\fBupdate\-reset\fP \fR[\fIpath\-to\-tap\-repository\fP \.\.\.]" +.TP +\fB\-v\fP, \fB\-\-verbose\fP +Print the directories checked and \fBgit\fP operations performed\. +.TP +\fB\-d\fP, \fB\-\-debug\fP +Display a trace of all shell commands as they are executed\. +.SS "\fBupdate\-reset\fP \fR[\fItap\fP \.\.\.]" Fetch and reset Homebrew and all tap repositories (or any specified \fIrepository\fP) using \fBgit\fP(1) to their latest \fBorigin/HEAD\fP\&\. .P \fINote:\fP this will destroy all your uncommitted or committed changes\.