| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2016-04-17 09:19:35 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-30 21:29:43 +00:00
										 |  |  |   def __prefix_args | 
					
						
							|  |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							|  |  |  |       usage_banner <<~EOS | 
					
						
							|  |  |  |         `--prefix` [<formula>] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Display Homebrew's install path. *Default:* `/usr/local` on macOS and | 
					
						
							|  |  |  |         `/home/linuxbrew/.linuxbrew` on Linux. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-18 12:13:43 -04:00
										 |  |  |         If <formula> is provided, display the location in the Cellar where <formula> | 
					
						
							| 
									
										
										
										
											2019-01-30 21:29:43 +00:00
										 |  |  |         is or would be installed. | 
					
						
							|  |  |  |       EOS | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   def __prefix | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  |     args = __prefix_args.parse | 
					
						
							| 
									
										
										
										
											2019-01-30 21:29:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-04 17:28:15 +00:00
										 |  |  |     if args.no_named? | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |       puts HOMEBREW_PREFIX | 
					
						
							|  |  |  |     else | 
					
						
							| 
									
										
										
										
											2020-08-19 10:34:48 -04:00
										 |  |  |       puts args.named.to_resolved_formulae.map { |f| | 
					
						
							| 
									
										
										
										
											2020-08-21 12:10:44 -07:00
										 |  |  |         f.opt_prefix.exist? ? f.opt_prefix : f.latest_installed_prefix | 
					
						
							| 
									
										
										
										
											2017-02-12 16:17:56 +00:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |