mirror of
https://github.com/gosticks/brew.git
synced 2026-08-26 19:40:21 +00:00
Refactor command handling code
Don’t rely on having external commands always present in the PATH in order to find them. Instead, provide an accessory method to Tap so they can be added and used when needed. While we’re here, do some general refactoring and cleanup of the command code in these places.
This commit is contained in:
@@ -8,15 +8,16 @@ 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)
|
||||
|
||||
if (path = Commands.path(cmd))
|
||||
puts path
|
||||
elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb"))
|
||||
puts path
|
||||
else
|
||||
odie "Unknown command: #{cmd}"
|
||||
end
|
||||
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(ARGV.first, ARGV.first)
|
||||
|
||||
path = Commands.path(cmd)
|
||||
|
||||
cmd_paths = PATH.new(ENV["PATH"]).append(Tap.cmd_directories) unless path
|
||||
path ||= which("brew-#{cmd}", cmd_paths)
|
||||
path ||= which("brew-#{cmd}.rb", cmd_paths)
|
||||
|
||||
odie "Unknown command: #{cmd}" unless path
|
||||
puts path
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user