| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  | require "fetch" | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2014-03-10 14:56:03 -05: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:21 +00:00
										 |  |  |   def __cache_args | 
					
						
							|  |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							|  |  |  |       usage_banner <<~EOS | 
					
						
							|  |  |  |         `--cache` [<options>] [<formula>] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         Display Homebrew's download cache. See also `HOMEBREW_CACHE`. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         If <formula> is provided, display the file or directory used to cache <formula>. | 
					
						
							|  |  |  |       EOS | 
					
						
							|  |  |  |       switch "-s", "--build-from-source", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Show the cache file used when building from source." | 
					
						
							| 
									
										
										
										
											2019-01-30 21:29:21 +00:00
										 |  |  |       switch "--force-bottle", | 
					
						
							| 
									
										
										
										
											2019-04-30 08:44:35 +01:00
										 |  |  |              description: "Show the cache file used when pouring a bottle." | 
					
						
							| 
									
										
										
										
											2019-01-30 21:29:21 +00:00
										 |  |  |       conflicts "--build-from-source", "--force-bottle" | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |   def __cache | 
					
						
							| 
									
										
										
										
											2019-01-30 21:29:21 +00:00
										 |  |  |     __cache_args.parse | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |     if ARGV.named.empty? | 
					
						
							|  |  |  |       puts HOMEBREW_CACHE | 
					
						
							|  |  |  |     else | 
					
						
							| 
									
										
										
										
											2014-03-10 14:56:03 -05:00
										 |  |  |       ARGV.formulae.each do |f| | 
					
						
							| 
									
										
										
										
											2018-06-05 23:19:18 -04:00
										 |  |  |         if Fetch.fetch_bottle?(f) | 
					
						
							| 
									
										
										
										
											2014-03-10 14:56:03 -05:00
										 |  |  |           puts f.bottle.cached_download | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           puts f.cached_download | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |