| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: false | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 08:29:14 +02:00
										 |  |  | module Cask | 
					
						
							| 
									
										
										
										
											2018-09-04 08:45:48 +01:00
										 |  |  |   class Cmd | 
					
						
							| 
									
										
										
										
											2020-08-19 10:34:07 +02:00
										 |  |  |     # Implementation of the `brew cask outdated` command. | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # @api private | 
					
						
							| 
									
										
										
										
											2017-05-20 19:08:03 +02:00
										 |  |  |     class Outdated < AbstractCommand | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |       extend T::Sig | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       sig { returns(String) } | 
					
						
							| 
									
										
										
										
											2020-08-01 02:30:46 +02:00
										 |  |  |       def self.description | 
					
						
							|  |  |  |         "List the outdated installed casks." | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2017-05-20 03:38:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-01 02:30:46 +02:00
										 |  |  |       def self.parser | 
					
						
							|  |  |  |         super do | 
					
						
							|  |  |  |           switch "--greedy", | 
					
						
							|  |  |  |                  description: "Also include casks which specify `auto_updates true` or `version :latest`." | 
					
						
							|  |  |  |           switch "--json", | 
					
						
							|  |  |  |                  description: "Print a JSON representation of outdated casks." | 
					
						
							| 
									
										
										
										
											2017-02-27 22:33:34 +02:00
										 |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |       sig { void } | 
					
						
							| 
									
										
										
										
											2020-04-26 21:13:19 +08:00
										 |  |  |       def run | 
					
						
							| 
									
										
										
										
											2020-10-01 00:57:02 +02:00
										 |  |  |         outdated_casks = casks(alternative: -> { Caskroom.casks(config: Config.from_args(args)) }).select do |cask| | 
					
						
							| 
									
										
										
										
											2020-08-01 02:30:46 +02:00
										 |  |  |           odebug "Checking update info of Cask #{cask}" | 
					
						
							| 
									
										
										
										
											2020-08-19 17:12:32 +01:00
										 |  |  |           cask.outdated?(greedy: args.greedy?) | 
					
						
							| 
									
										
										
										
											2020-08-01 02:30:46 +02:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-02-27 22:33:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-01 02:30:46 +02:00
										 |  |  |         verbose = ($stdout.tty? || args.verbose?) && !args.quiet? | 
					
						
							|  |  |  |         output = outdated_casks.map { |cask| cask.outdated_info(args.greedy?, verbose, args.json?) } | 
					
						
							| 
									
										
										
										
											2017-02-27 22:33:34 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-01 02:30:46 +02:00
										 |  |  |         puts args.json? ? JSON.generate(output) : output | 
					
						
							| 
									
										
										
										
											2017-02-27 22:33:34 +02:00
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |