command: use Commands module.
This commit is contained in:
parent
0bb7fda143
commit
49dcbee99c
@ -1,13 +1,15 @@
|
|||||||
#: * `command` <cmd>:
|
#: * `command` <cmd>:
|
||||||
#: Display the path to the file which is used when invoking `brew` <cmd>.
|
#: Display the path to the file which is used when invoking `brew` <cmd>.
|
||||||
|
|
||||||
|
require "commands"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
def command
|
def command
|
||||||
abort "This command requires a command argument" if ARGV.empty?
|
abort "This command requires a command argument" if ARGV.empty?
|
||||||
cmd = ARGV.first
|
cmd = ARGV.first
|
||||||
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
|
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
|
||||||
|
|
||||||
if (path = internal_command_path cmd)
|
if (path = Commands.path(cmd))
|
||||||
puts path
|
puts path
|
||||||
elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb"))
|
elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb"))
|
||||||
puts path
|
puts path
|
||||||
@ -15,13 +17,4 @@ module Homebrew
|
|||||||
odie "Unknown command: #{cmd}"
|
odie "Unknown command: #{cmd}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def internal_command_path(cmd)
|
|
||||||
extensions = %w[rb sh]
|
|
||||||
paths = extensions.map { |ext| HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.#{ext}" }
|
|
||||||
paths += extensions.map { |ext| HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.#{ext}" }
|
|
||||||
paths.find { |p| p.file? }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user