| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2019-01-20 20:42:15 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-20 20:42:15 +05:30
										 |  |  |   def commands_args | 
					
						
							|  |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							|  |  |  |       usage_banner <<~EOS | 
					
						
							|  |  |  |         `commands` [<options>] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-19 22:44:50 -04:00
										 |  |  |         Show lists of built-in and external commands. | 
					
						
							| 
									
										
										
										
											2019-01-20 20:42:15 +05:30
										 |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2019-08-21 12:42:09 -04:00
										 |  |  |       switch :quiet, | 
					
						
							| 
									
										
										
										
											2019-08-19 22:44:50 -04:00
										 |  |  |              description: "List only the names of commands without category headers." | 
					
						
							| 
									
										
										
										
											2019-01-20 20:42:15 +05:30
										 |  |  |       switch "--include-aliases", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              depends_on:  "--quiet", | 
					
						
							| 
									
										
										
										
											2019-08-20 00:04:14 -04:00
										 |  |  |              description: "Include aliases of internal commands." | 
					
						
							| 
									
										
										
										
											2019-01-20 20:42:15 +05:30
										 |  |  |       switch :verbose | 
					
						
							|  |  |  |       switch :debug | 
					
						
							| 
									
										
										
										
											2019-12-13 16:50:54 -05:00
										 |  |  |       max_named 0
 | 
					
						
							| 
									
										
										
										
											2019-01-20 20:42:15 +05:30
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-14 16:58:26 -07:00
										 |  |  |   def commands | 
					
						
							| 
									
										
										
										
											2019-01-20 20:42:15 +05:30
										 |  |  |     commands_args.parse | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if args.quiet? | 
					
						
							| 
									
										
										
										
											2020-02-02 17:05:45 +01:00
										 |  |  |       puts Formatter.columns(Commands.commands(aliases: args.include_aliases?)) | 
					
						
							| 
									
										
										
										
											2017-11-05 15:37:57 +00:00
										 |  |  |       return | 
					
						
							| 
									
										
										
										
											2013-09-14 16:58:26 -07:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-11-05 15:37:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 17:05:45 +01:00
										 |  |  |     ohai "Built-in commands", Formatter.columns(Commands.internal_commands) | 
					
						
							| 
									
										
										
										
											2017-11-05 15:37:57 +00:00
										 |  |  |     puts | 
					
						
							| 
									
										
										
										
											2020-02-02 17:05:45 +01:00
										 |  |  |     ohai "Built-in developer commands", Formatter.columns(Commands.internal_developer_commands) | 
					
						
							| 
									
										
										
										
											2017-11-05 15:37:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-02 17:05:45 +01:00
										 |  |  |     external_commands = Commands.external_commands | 
					
						
							|  |  |  |     return if external_commands.blank? | 
					
						
							| 
									
										
										
										
											2017-11-05 15:37:57 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     puts | 
					
						
							| 
									
										
										
										
											2020-02-02 17:05:45 +01:00
										 |  |  |     ohai "External commands", Formatter.columns(external_commands) | 
					
						
							| 
									
										
										
										
											2015-07-09 19:50:53 +08:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-09-14 16:58:26 -07:00
										 |  |  | end |