| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-05-23 15:20:24 +08:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module Cask | 
					
						
							|  |  |  |   class Cmd | 
					
						
							| 
									
										
										
										
											2020-08-19 10:34:07 +02:00
										 |  |  |     # Implementation of the `brew cask --cache` command. | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # @api private | 
					
						
							| 
									
										
										
										
											2019-05-23 15:20:24 +08:00
										 |  |  |     class Cache < AbstractCommand | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |       extend T::Sig | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       sig { override.returns(T.nilable(T.any(Integer, Symbol))) } | 
					
						
							| 
									
										
										
										
											2020-08-01 02:30:46 +02:00
										 |  |  |       def self.min_named | 
					
						
							|  |  |  |         :cask | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |       sig { returns(String) } | 
					
						
							| 
									
										
										
										
											2020-08-01 02:30:46 +02:00
										 |  |  |       def self.description | 
					
						
							|  |  |  |         "Display the file used to cache a <cask>." | 
					
						
							| 
									
										
										
										
											2019-05-23 15:20:24 +08:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |       sig { returns(String) } | 
					
						
							| 
									
										
										
										
											2020-08-01 02:30:46 +02:00
										 |  |  |       def self.command_name | 
					
						
							|  |  |  |         "--cache" | 
					
						
							| 
									
										
										
										
											2019-05-23 15:20:24 +08:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |       sig { void } | 
					
						
							| 
									
										
										
										
											2019-05-23 15:20:24 +08:00
										 |  |  |       def run | 
					
						
							|  |  |  |         casks.each do |cask| | 
					
						
							| 
									
										
										
										
											2020-06-22 11:29:46 -04:00
										 |  |  |           puts self.class.cached_location(cask) | 
					
						
							| 
									
										
										
										
											2019-05-23 15:20:24 +08:00
										 |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 10:37:31 -04:00
										 |  |  |       def self.cached_location(cask) | 
					
						
							| 
									
										
										
										
											2020-08-18 00:23:23 +01:00
										 |  |  |         require "cask/download" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 10:37:31 -04:00
										 |  |  |         Download.new(cask).downloader.cached_location | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2019-05-23 15:20:24 +08:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |