aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/help.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/cmd/help.rb')
-rw-r--r--Library/Homebrew/cmd/help.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/Library/Homebrew/cmd/help.rb b/Library/Homebrew/cmd/help.rb
index f729c0e8c..76eef90a8 100644
--- a/Library/Homebrew/cmd/help.rb
+++ b/Library/Homebrew/cmd/help.rb
@@ -39,4 +39,23 @@ module Homebrew
def help_s
HOMEBREW_HELP
end
+
+ def help_for_command(cmd)
+ cmd_path = if File.exist?(HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh")
+ HOMEBREW_LIBRARY_PATH/"cmd/#{cmd}.sh"
+ elsif ARGV.homebrew_developer? && 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 ARGV.homebrew_developer? && File.exist?(HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb")
+ HOMEBREW_LIBRARY_PATH/"dev-cmd/#{cmd}.rb"
+ end
+ return if cmd_path.nil?
+
+ cmd_path.read.
+ split("\n").
+ grep(/^#:/).
+ map { |line| line.slice(2..-1).delete("`").sub(/^ \* /, "brew ") }.
+ join("\n")
+ end
end