| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-07 20:09:22 +01:00
										 |  |  | require "commands" | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2016-09-07 20:09:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-26 15:19:27 +08:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-20 20:08:14 +05:30
										 |  |  |   def command_args | 
					
						
							|  |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							|  |  |  |       usage_banner <<~EOS | 
					
						
							|  |  |  |         `command` <cmd> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-20 00:04:14 -04:00
										 |  |  |         Display the path to the file being used when invoking `brew` <cmd>. | 
					
						
							| 
									
										
										
										
											2019-01-20 20:08:14 +05:30
										 |  |  |       EOS | 
					
						
							|  |  |  |       switch :verbose | 
					
						
							|  |  |  |       switch :debug | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-26 15:19:27 +08:00
										 |  |  |   def command | 
					
						
							| 
									
										
										
										
											2019-01-20 20:08:14 +05:30
										 |  |  |     command_args.parse | 
					
						
							|  |  |  |     abort "This command requires a command argument" if args.remaining.empty? | 
					
						
							| 
									
										
										
										
											2015-06-26 15:19:27 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-20 20:08:14 +05:30
										 |  |  |     cmd = HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(args.remaining.first, args.remaining.first) | 
					
						
							| 
									
										
										
										
											2017-11-05 15:37:57 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     path = Commands.path(cmd) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     cmd_paths = PATH.new(ENV["PATH"]).append(Tap.cmd_directories) unless path | 
					
						
							|  |  |  |     path ||= which("brew-#{cmd}", cmd_paths) | 
					
						
							|  |  |  |     path ||= which("brew-#{cmd}.rb", cmd_paths) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     odie "Unknown command: #{cmd}" unless path | 
					
						
							|  |  |  |     puts path | 
					
						
							| 
									
										
										
										
											2015-06-26 15:19:27 +08:00
										 |  |  |   end | 
					
						
							|  |  |  | end |