diff options
| author | Mike McQuaid | 2016-09-07 20:09:22 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2016-09-08 20:46:55 +0100 |
| commit | 49dcbee99c46d92d65e9132a555ed3fc2865c1e6 (patch) | |
| tree | ff981152c67331f1a09b862e8b28408313779415 | |
| parent | 0bb7fda143f3a609fdfed27e84422ff55f85db02 (diff) | |
| download | brew-49dcbee99c46d92d65e9132a555ed3fc2865c1e6.tar.bz2 | |
command: use Commands module.
| -rw-r--r-- | Library/Homebrew/cmd/command.rb | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/Library/Homebrew/cmd/command.rb b/Library/Homebrew/cmd/command.rb index bab0257c8..b76468f62 100644 --- a/Library/Homebrew/cmd/command.rb +++ b/Library/Homebrew/cmd/command.rb @@ -1,13 +1,15 @@ #: * `command` <cmd>: #: Display the path to the file which is used when invoking `brew` <cmd>. +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) - if (path = internal_command_path cmd) + if (path = Commands.path(cmd)) puts path elsif (path = which("brew-#{cmd}") || which("brew-#{cmd}.rb")) puts path @@ -15,13 +17,4 @@ module Homebrew odie "Unknown command: #{cmd}" 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 |
