2011-03-13 12:54:30 +00:00
|
|
|
HOMEBREW_HELP = <<-EOS
|
|
|
|
Example usage:
|
2013-01-30 09:30:01 -08:00
|
|
|
brew [info | home | options ] [FORMULA...]
|
2011-03-13 12:54:30 +00:00
|
|
|
brew install FORMULA...
|
|
|
|
brew uninstall FORMULA...
|
|
|
|
brew search [foo]
|
|
|
|
brew list [FORMULA...]
|
|
|
|
brew update
|
2015-08-07 19:36:29 +08:00
|
|
|
brew upgrade [FORMULA...]
|
2013-10-14 11:00:09 -04:00
|
|
|
brew pin/unpin [FORMULA...]
|
2011-03-13 12:54:30 +00:00
|
|
|
|
|
|
|
Troubleshooting:
|
|
|
|
brew doctor
|
|
|
|
brew install -vd FORMULA
|
2014-04-26 23:31:39 -07:00
|
|
|
brew [--env | config]
|
2011-03-13 12:54:30 +00:00
|
|
|
|
|
|
|
Brewing:
|
|
|
|
brew create [URL [--no-fetch]]
|
|
|
|
brew edit [FORMULA...]
|
2016-04-03 14:03:33 +01:00
|
|
|
https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Formula-Cookbook.md
|
2011-03-13 12:54:30 +00:00
|
|
|
|
|
|
|
Further help:
|
|
|
|
man brew
|
|
|
|
brew home
|
|
|
|
EOS
|
|
|
|
|
|
|
|
# NOTE Keep the lenth of vanilla --help less than 25 lines!
|
|
|
|
# This is because the default Terminal height is 25 lines. Scrolling sucks
|
|
|
|
# and concision is important. If more help is needed we should start
|
|
|
|
# specialising help like the gem command does.
|
|
|
|
# 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!
|
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2016-04-17 03:45:10 +02:00
|
|
|
def help(cmd = nil, empty_argv = false)
|
|
|
|
# Handle `brew` (no arguments).
|
|
|
|
if empty_argv
|
|
|
|
$stderr.puts HOMEBREW_HELP
|
|
|
|
exit 1
|
|
|
|
end
|
|
|
|
|
|
|
|
# Handle `brew (-h|--help|--usage|-?|help)` (no other arguments).
|
|
|
|
if cmd.nil?
|
|
|
|
puts HOMEBREW_HELP
|
|
|
|
exit 0
|
|
|
|
end
|
|
|
|
|
|
|
|
# Get help text and if `nil` (external commands), resume in `brew.rb`.
|
|
|
|
help_text = help_for_command(cmd)
|
|
|
|
return if help_text.nil?
|
|
|
|
|
|
|
|
# Display help for internal command (or generic help if undocumented).
|
|
|
|
if help_text.empty?
|
|
|
|
opoo "No help available for '#{cmd}' command."
|
|
|
|
help_text = HOMEBREW_HELP
|
|
|
|
end
|
|
|
|
puts help_text
|
|
|
|
exit 0
|
2011-03-13 12:54:30 +00:00
|
|
|
end
|
2015-08-03 13:09:07 +01:00
|
|
|
|
2016-04-17 03:45:10 +02:00
|
|
|
private
|
|
|
|
|
2016-04-03 20:17:01 +02:00
|
|
|
def help_for_command(cmd)
|
2016-04-11 21:47:08 +08:00
|
|
|
cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
|
2016-04-03 20:17:01 +02:00
|
|
|
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(/^#:/).
|
2016-04-12 14:36:15 +08:00
|
|
|
map do |line|
|
|
|
|
line.slice(2..-1).sub(/^ \* /, "#{Tty.highlight}brew#{Tty.reset} ").
|
|
|
|
gsub(/`(.*?)`/, "#{Tty.highlight}\\1#{Tty.reset}").
|
|
|
|
gsub(/<(.*?)>/, "#{Tty.em}\\1#{Tty.reset}")
|
|
|
|
end.join("\n")
|
2016-04-03 20:17:01 +02:00
|
|
|
end
|
2011-03-13 12:54:30 +00:00
|
|
|
end
|