--version.rb 719 Bytes
Newer Older
Markus Reiter's avatar
Markus Reiter committed
1
# typed: true
2
3
# frozen_string_literal: true

4
require "cli/parser"
5
6

module Homebrew
Markus Reiter's avatar
Markus Reiter committed
7
8
  extend T::Sig

9
10
  module_function

Markus Reiter's avatar
Markus Reiter committed
11
  sig { returns(CLI::Parser) }
Mike McQuaid's avatar
Mike McQuaid committed
12
13
14
15
16
  def __version_args
    Homebrew::CLI::Parser.new do
      usage_banner <<~EOS
        `--version`

EricFromCanada's avatar
EricFromCanada committed
17
        Print the version numbers of Homebrew, Homebrew/homebrew-core and Homebrew/homebrew-cask
18
        (if tapped) to standard output.
Mike McQuaid's avatar
Mike McQuaid committed
19
      EOS
EricFromCanada's avatar
EricFromCanada committed
20

21
      max_named 0
Mike McQuaid's avatar
Mike McQuaid committed
22
23
24
    end
  end

25
  def __version
Mike McQuaid's avatar
Mike McQuaid committed
26
27
    __version_args.parse

28
    puts "Homebrew #{HOMEBREW_VERSION}"
29
30
    puts "#{CoreTap.instance.full_name} #{CoreTap.instance.version_string}"
    puts "#{Tap.default_cask_tap.full_name} #{Tap.default_cask_tap.version_string}" if Tap.default_cask_tap.installed?
31
32
  end
end