| 
									
										
										
										
											2020-10-10 14:16:11 +02:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											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 home` command. | 
					
						
							|  |  |  |     # | 
					
						
							|  |  |  |     # @api private | 
					
						
							| 
									
										
										
										
											2017-05-20 19:08:03 +02:00
										 |  |  |     class Home < 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 | 
					
						
							|  |  |  |         "Opens the homepage of the given <cask>. If no cask is given, opens the Homebrew homepage." | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |       sig { void } | 
					
						
							| 
									
										
										
										
											2017-05-19 21:48:21 +02:00
										 |  |  |       def run | 
					
						
							| 
									
										
										
										
											2017-06-13 17:14:01 +02:00
										 |  |  |         if casks.none? | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |           odebug "Opening project homepage" | 
					
						
							| 
									
										
										
										
											2019-04-13 19:40:35 +01:00
										 |  |  |           self.class.open_url "https://brew.sh/" | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |         else | 
					
						
							| 
									
										
										
										
											2017-05-19 21:48:21 +02:00
										 |  |  |           casks.each do |cask| | 
					
						
							|  |  |  |             odebug "Opening homepage for Cask #{cask}" | 
					
						
							|  |  |  |             self.class.open_url cask.homepage | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-19 21:48:21 +02:00
										 |  |  |       def self.open_url(url) | 
					
						
							|  |  |  |         SystemCommand.run!(OS::PATH_OPEN, args: ["--", url]) | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2016-09-24 13:52:43 +02:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-08-18 22:11:42 +03:00
										 |  |  |   end | 
					
						
							|  |  |  | end |