--repository.rb 663 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
  def __repository_args
    Homebrew::CLI::Parser.new do
      usage_banner <<~EOS
15
        `--repository`, `--repo` [<user>`/`<repo>]
Mike McQuaid's avatar
Mike McQuaid committed
16
17
18
19
20
21
22
23

        Display where Homebrew's `.git` directory is located.

        If <user>`/`<repo> are provided, display where tap <user>`/`<repo>'s directory is located.
      EOS
    end
  end

24
  def __repository
Markus Reiter's avatar
Markus Reiter committed
25
    args = __repository_args.parse
Mike McQuaid's avatar
Mike McQuaid committed
26

27
    if args.no_named?
28
29
      puts HOMEBREW_REPOSITORY
    else
30
      puts args.named.map { |tap| Tap.fetch(tap).path }
31
    end
32
33
  end
end