| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  | HOMEBREW_HELP = <<~EOS.freeze | 
					
						
							| 
									
										
										
										
											2017-05-29 18:24:52 +01:00
										 |  |  |   Example usage: | 
					
						
							|  |  |  |     brew search [TEXT|/REGEX/] | 
					
						
							| 
									
										
										
										
											2018-03-30 14:57:38 +01:00
										 |  |  |     brew info [FORMULA...] | 
					
						
							| 
									
										
										
										
											2017-05-29 18:24:52 +01:00
										 |  |  |     brew install FORMULA... | 
					
						
							|  |  |  |     brew update | 
					
						
							|  |  |  |     brew upgrade [FORMULA...] | 
					
						
							|  |  |  |     brew uninstall FORMULA... | 
					
						
							|  |  |  |     brew list [FORMULA...] | 
					
						
							| 
									
										
										
										
											2011-03-13 12:54:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-29 18:24:52 +01:00
										 |  |  |   Troubleshooting: | 
					
						
							|  |  |  |     brew config | 
					
						
							|  |  |  |     brew doctor | 
					
						
							| 
									
										
										
										
											2018-03-30 14:57:38 +01:00
										 |  |  |     brew install --verbose --debug FORMULA | 
					
						
							| 
									
										
										
										
											2011-03-13 12:54:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-30 14:57:38 +01:00
										 |  |  |   Contributing: | 
					
						
							| 
									
										
										
										
											2017-05-29 18:24:52 +01:00
										 |  |  |     brew create [URL [--no-fetch]] | 
					
						
							|  |  |  |     brew edit [FORMULA...] | 
					
						
							| 
									
										
										
										
											2011-03-13 12:54:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-29 18:24:52 +01:00
										 |  |  |   Further help: | 
					
						
							| 
									
										
										
										
											2018-03-30 14:57:38 +01:00
										 |  |  |     brew commands | 
					
						
							| 
									
										
										
										
											2017-05-29 18:24:52 +01:00
										 |  |  |     brew help [COMMAND] | 
					
						
							| 
									
										
										
										
											2018-03-30 14:57:38 +01:00
										 |  |  |     man brew | 
					
						
							|  |  |  |     https://docs.brew.sh | 
					
						
							| 
									
										
										
										
											2011-03-13 12:54:30 +00:00
										 |  |  | 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! | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-07 20:09:29 +01:00
										 |  |  | require "commands" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-19 07:24:21 +02:00
										 |  |  |   def help(cmd = nil, flags = {}) | 
					
						
							|  |  |  |     # Resolve command aliases and find file containing the implementation. | 
					
						
							|  |  |  |     if cmd | 
					
						
							|  |  |  |       cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd) | 
					
						
							| 
									
										
										
										
											2016-09-07 20:09:29 +01:00
										 |  |  |       path = Commands.path(cmd) | 
					
						
							| 
									
										
										
										
											2016-10-01 18:25:16 +01:00
										 |  |  |       path ||= which("brew-#{cmd}") | 
					
						
							|  |  |  |       path ||= which("brew-#{cmd}.rb") | 
					
						
							| 
									
										
										
										
											2016-04-19 07:24:21 +02:00
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-19 07:33:13 +02:00
										 |  |  |     # Display command-specific (or generic) help in response to `UsageError`. | 
					
						
							|  |  |  |     if (error_message = flags[:usage_error]) | 
					
						
							|  |  |  |       $stderr.puts path ? command_help(path) : HOMEBREW_HELP | 
					
						
							|  |  |  |       $stderr.puts | 
					
						
							|  |  |  |       onoe error_message | 
					
						
							|  |  |  |       exit 1
 | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-17 03:45:10 +02:00
										 |  |  |     # Handle `brew` (no arguments). | 
					
						
							| 
									
										
										
										
											2016-04-19 07:24:21 +02:00
										 |  |  |     if flags[:empty_argv] | 
					
						
							| 
									
										
										
										
											2016-04-17 03:45:10 +02:00
										 |  |  |       $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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-01 18:25:16 +01:00
										 |  |  |     # Resume execution in `brew.rb` for unknown commands. | 
					
						
							| 
									
										
										
										
											2016-04-19 07:24:21 +02:00
										 |  |  |     return if path.nil? | 
					
						
							| 
									
										
										
										
											2016-04-17 03:45:10 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Display help for internal command (or generic help if undocumented). | 
					
						
							| 
									
										
										
										
											2016-04-19 07:24:21 +02:00
										 |  |  |     puts command_help(path) | 
					
						
							| 
									
										
										
										
											2016-04-17 03:45:10 +02:00
										 |  |  |     exit 0
 | 
					
						
							| 
									
										
										
										
											2011-03-13 12:54:30 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-19 07:24:21 +02:00
										 |  |  |   def command_help(path) | 
					
						
							| 
									
										
										
										
											2018-03-15 16:25:14 +00:00
										 |  |  |     help_lines = command_help_lines(path) | 
					
						
							| 
									
										
										
										
											2016-04-19 07:24:21 +02:00
										 |  |  |     if help_lines.empty? | 
					
						
							|  |  |  |       opoo "No help text in: #{path}" if ARGV.homebrew_developer? | 
					
						
							|  |  |  |       HOMEBREW_HELP | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       help_lines.map do |line| | 
					
						
							| 
									
										
										
										
											2018-03-15 16:25:14 +00:00
										 |  |  |         line.sub(/^  \* /, "#{Tty.bold}brew#{Tty.reset} ") | 
					
						
							| 
									
										
										
										
											2016-09-17 03:21:51 +02:00
										 |  |  |             .gsub(/`(.*?)`/, "#{Tty.bold}\\1#{Tty.reset}") | 
					
						
							|  |  |  |             .gsub(%r{<([^\s]+?://[^\s]+?)>}) { |url| Formatter.url(url) } | 
					
						
							|  |  |  |             .gsub(/<(.*?)>/, "#{Tty.underline}\\1#{Tty.reset}") | 
					
						
							|  |  |  |             .gsub("@hide_from_man_page", "") | 
					
						
							| 
									
										
										
										
											2016-06-28 08:08:12 -07:00
										 |  |  |       end.join.strip | 
					
						
							| 
									
										
										
										
											2016-04-19 07:24:21 +02:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-04-03 20:17:01 +02:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-03-13 12:54:30 +00:00
										 |  |  | end |