Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stub Ruby commands for all Bash commands. #17742

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Library/Homebrew/abstract_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,12 @@

sig { abstract.void }
def run; end

sig { void }
def raise_sh_command_error!
raise StandardError,

Check warning on line 67 in Library/Homebrew/abstract_command.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/abstract_command.rb#L67

Added line #L67 was not covered by tests
"This command is just here for completions generation. " \
"It's actually defined in `cmd/#{self.class.command_name}.sh` instead."
end
end
end
11 changes: 1 addition & 10 deletions Library/Homebrew/cmd/--repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,16 +17,10 @@ def self.command_name = "--repository"
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
6 changes: 1 addition & 5 deletions Library/Homebrew/cmd/--repository.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#: * `--repository`, `--repo` [<tap> ...]
#:
#: Display where Homebrew's Git repository is located.
#:
#: If <user>`/`<repo> are provided, display where tap <user>`/`<repo>'s directory is located.
# Documentation defined in Library/Homebrew/cmd/--repository.rb

# HOMEBREW_REPOSITORY, HOMEBREW_LIBRARY are set by brew.sh
# shellcheck disable=SC2154
Expand Down
23 changes: 23 additions & 0 deletions Library/Homebrew/cmd/--version.rb
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 13 in Library/Homebrew/cmd/--version.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/--version.rb#L13

Added line #L13 was not covered by tests
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
4 changes: 1 addition & 3 deletions Library/Homebrew/cmd/--version.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 19 additions & 0 deletions Library/Homebrew/cmd/casks.rb
Original file line number Diff line number Diff line change
@@ -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."

Check warning on line 12 in Library/Homebrew/cmd/casks.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/casks.rb#L12

Added line #L12 was not covered by tests
end

sig { override.void }
def run = raise_sh_command_error!
end
end
end
5 changes: 1 addition & 4 deletions Library/Homebrew/cmd/casks.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 17 additions & 0 deletions Library/Homebrew/cmd/formulae.rb
Original file line number Diff line number Diff line change
@@ -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."

Check warning on line 10 in Library/Homebrew/cmd/formulae.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/formulae.rb#L10

Added line #L10 was not covered by tests
end

sig { override.void }
def run = raise_sh_command_error!
end
end
end
5 changes: 1 addition & 4 deletions Library/Homebrew/cmd/formulae.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
21 changes: 21 additions & 0 deletions Library/Homebrew/cmd/setup-ruby.rb
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 10 in Library/Homebrew/cmd/setup-ruby.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/setup-ruby.rb#L10

Added line #L10 was not covered by tests
Installs and configures Homebrew's Ruby. If `command` is passed, it will only run Bundler if necessary for that command.
EOS

named_args :command

Check warning on line 14 in Library/Homebrew/cmd/setup-ruby.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/setup-ruby.rb#L14

Added line #L14 was not covered by tests
end

sig { override.void }
def run = raise_sh_command_error!
end
end
end
7 changes: 1 addition & 6 deletions Library/Homebrew/cmd/setup-ruby.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
29 changes: 29 additions & 0 deletions Library/Homebrew/cmd/shellenv.rb
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 10 in Library/Homebrew/cmd/shellenv.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/shellenv.rb#L10

Added line #L10 was not covered by tests
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

Check warning on line 22 in Library/Homebrew/cmd/shellenv.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/shellenv.rb#L22

Added line #L22 was not covered by tests
end

sig { override.void }
def run = raise_sh_command_error!
end
end
end
11 changes: 1 addition & 10 deletions Library/Homebrew/cmd/shellenv.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
23 changes: 23 additions & 0 deletions Library/Homebrew/cmd/update-reset.rb
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 10 in Library/Homebrew/cmd/update-reset.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-reset.rb#L10

Added line #L10 was not covered by tests
Fetch and reset Homebrew and all tap repositories (or any specified <repository>) using `git`(1) to their latest `origin/HEAD`.

*Note:* this will destroy all your uncommitted or committed changes.
EOS

named_args :repository

Check warning on line 16 in Library/Homebrew/cmd/update-reset.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/update-reset.rb#L16

Added line #L16 was not covered by tests
end

sig { override.void }
def run = raise_sh_command_error!
end
end
end
6 changes: 1 addition & 5 deletions Library/Homebrew/cmd/update-reset.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#: * `update-reset` [<path-to-tap-repository> ...]
#:
#: Fetch and reset Homebrew and all tap repositories (or any specified <repository>) 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.
Expand Down
31 changes: 31 additions & 0 deletions Library/Homebrew/cmd/update.rb
Original file line number Diff line number Diff line change
@@ -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
12 changes: 1 addition & 11 deletions Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
#: * `update` [<options>]
#:
#: 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
Expand Down
23 changes: 23 additions & 0 deletions Library/Homebrew/cmd/vendor-install.rb
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 10 in Library/Homebrew/cmd/vendor-install.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/vendor-install.rb#L10

Added line #L10 was not covered by tests
Install Homebrew's portable Ruby.
EOS

named_args :target

Check warning on line 14 in Library/Homebrew/cmd/vendor-install.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/vendor-install.rb#L14

Added line #L14 was not covered by tests

hide_from_man_page!

Check warning on line 16 in Library/Homebrew/cmd/vendor-install.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/cmd/vendor-install.rb#L16

Added line #L16 was not covered by tests
end

sig { override.void }
def run = raise_sh_command_error!
end
end
end
5 changes: 1 addition & 4 deletions Library/Homebrew/cmd/vendor-install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#: @hide_from_man_page
#: * `vendor-install` [<target>]
#:
#: 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,
Expand Down
19 changes: 19 additions & 0 deletions Library/Homebrew/dev-cmd/rubocop.rb
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 10 in Library/Homebrew/dev-cmd/rubocop.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/rubocop.rb#L10

Added line #L10 was not covered by tests
Installs, configures and runs Homebrew's `rubocop`.
EOS
end

sig { override.void }
def run = raise_sh_command_error!
end
end
end
4 changes: 1 addition & 3 deletions Library/Homebrew/dev-cmd/rubocop.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading
Loading