aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/command.rb
blob: 39e8ba6fc4f6ba64448fb99a76fedde88dcb397e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#:  * `command` <cmd>:
#:    Display the path to the file which is used when invoking `brew` <cmd>.

require "commands"

module Homebrew
  module_function

  def command
    abort "This command requires a command argument" if ARGV.empty?
    cmd = ARGV.first
    cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)

    if (path = Commands.path(cmd))
      puts path
    elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb"))
      puts path
    else
      odie "Unknown command: #{cmd}"
    end
  end
end