Move --version logic into cmd/--version.rb.

This commit is contained in:
Markus Reiter 2018-05-16 17:33:40 +02:00
parent 16fbcd09da
commit c53a52daee
4 changed files with 6 additions and 11 deletions

View File

@ -22,12 +22,6 @@ end
require "global"
if ARGV == %w[--version] || ARGV == %w[-v]
puts "Homebrew #{HOMEBREW_VERSION}"
puts "Homebrew/homebrew-core #{CoreTap.instance.version_string}"
exit 0
end
begin
trap("INT", std_trap) # restore default CTRL-C handler

View File

@ -232,6 +232,7 @@ case "$HOMEBREW_COMMAND" in
--repo) HOMEBREW_COMMAND="--repository" ;;
environment) HOMEBREW_COMMAND="--env" ;;
--config) HOMEBREW_COMMAND="config" ;;
-v) HOMEBREW_COMMAND="--version" ;;
esac
if [[ "$HOMEBREW_COMMAND" = "cask" ]]

View File

@ -5,10 +5,9 @@ module Homebrew
module_function
def __version
# As a special case, `--version` is implemented directly in `brew.rb`. This
# file merely serves as a container for the documentation. It also catches
# the case where running `brew --version` with additional arguments would
# produce a rather cryptic message about a non-existent `--version` command.
raise UsageError
odie "This command does not take arguments." if ARGV.any?
puts "Homebrew #{HOMEBREW_VERSION}"
puts "Homebrew/homebrew-core #{CoreTap.instance.version_string}"
end
end

View File

@ -83,6 +83,7 @@ HOMEBREW_INTERNAL_COMMAND_ALIASES = {
"--repo" => "--repository",
"environment" => "--env",
"--config" => "config",
"-v" => "--version",
}.freeze
require "set"