| 
									
										
										
										
											2020-11-25 17:03:23 +01:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 13:09:07 +01:00
										 |  |  | require "formula" | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2013-03-11 16:41:08 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2016-09-26 01:44:51 +02:00
										 |  |  |   module_function | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   sig { returns(CLI::Parser) } | 
					
						
							| 
									
										
										
										
											2018-11-11 20:06:40 +05:30
										 |  |  |   def pin_args | 
					
						
							|  |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							| 
									
										
										
										
											2021-01-15 15:04:02 -05:00
										 |  |  |       description <<~EOS | 
					
						
							| 
									
										
										
										
											2019-01-30 21:32:35 +00:00
										 |  |  |         Pin the specified <formula>, preventing them from being upgraded when | 
					
						
							|  |  |  |         issuing the `brew upgrade` <formula> command. See also `unpin`. | 
					
						
							| 
									
										
										
										
											2018-11-11 20:06:40 +05:30
										 |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-10 14:26:40 -05:00
										 |  |  |       named_args :installed_formula, min: 1
 | 
					
						
							| 
									
										
										
										
											2018-11-11 20:06:40 +05:30
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-11 16:41:08 +01:00
										 |  |  |   def pin | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  |     args = pin_args.parse | 
					
						
							| 
									
										
										
										
											2018-11-11 20:06:40 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-19 10:34:48 -04:00
										 |  |  |     args.named.to_resolved_formulae.each do |f| | 
					
						
							| 
									
										
										
										
											2013-04-16 01:43:26 -05:00
										 |  |  |       if f.pinned? | 
					
						
							|  |  |  |         opoo "#{f.name} already pinned" | 
					
						
							|  |  |  |       elsif !f.pinnable? | 
					
						
							|  |  |  |         onoe "#{f.name} not installed" | 
					
						
							|  |  |  |       else | 
					
						
							|  |  |  |         f.pin | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2013-03-11 16:41:08 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |