brew/Library/Homebrew/cmd/command.rb

21 lines
499 B
Ruby
Raw Normal View History

2016-04-08 16:28:43 +02:00
#: * `command` <cmd>:
#: Display the path to the file which is used when invoking `brew` <cmd>.
2016-09-07 20:09:22 +01:00
require "commands"
module Homebrew
def command
abort "This command requires a command argument" if ARGV.empty?
cmd = ARGV.first
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
2016-09-07 20:09:22 +01:00
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