From ae57057afae0a714143de090a62ea772b097569c Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 7 Sep 2016 20:09:29 +0100 Subject: [PATCH] help: use Commands module. --- Library/Homebrew/cmd/help.rb | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb index eae08395da..a6681c0b3d 100644 --- a/Library/Homebrew/cmd/help.rb +++ b/Library/Homebrew/cmd/help.rb @@ -31,12 +31,14 @@ EOS # NOTE Keep lines less than 80 characters! Wrapping is just not cricket. # NOTE The reason the string is at the top is so 25 lines is easy to measure! +require "commands" + module Homebrew def help(cmd = nil, flags = {}) # Resolve command aliases and find file containing the implementation. if cmd cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd) - path = command_path(cmd) + path = Commands.path(cmd) end # Display command-specific (or generic) help in response to `UsageError`. @@ -69,18 +71,6 @@ module Homebrew private - def command_path(cmd) - if File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh") - HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh") - HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.sh" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb") - HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.rb" - elsif File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb") - HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb" - end - end - def command_help(path) help_lines = path.read.lines.grep(/^#:/) if help_lines.empty?