| 
									
										
										
										
											2024-04-01 11:47:18 -07:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-01 11:47:18 -07:00
										 |  |  | require "abstract_command" | 
					
						
							| 
									
										
										
										
											2020-11-02 11:20:09 +00:00
										 |  |  | require "unlink" | 
					
						
							| 
									
										
										
										
											2015-09-06 15:25:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-06-18 22:41:47 -05:00
										 |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2024-04-01 11:47:18 -07:00
										 |  |  |   module Cmd | 
					
						
							|  |  |  |     class UnlinkCmd < AbstractCommand | 
					
						
							|  |  |  |       cmd_args do | 
					
						
							|  |  |  |         description <<~EOS | 
					
						
							|  |  |  |           Remove symlinks for <formula> from Homebrew's prefix. This can be useful | 
					
						
							|  |  |  |           for temporarily disabling a formula: | 
					
						
							|  |  |  |           `brew unlink` <formula> `&&` <commands> `&& brew link` <formula> | 
					
						
							|  |  |  |         EOS | 
					
						
							|  |  |  |         switch "-n", "--dry-run", | 
					
						
							|  |  |  |                description: "List files which would be unlinked without actually unlinking or " \ | 
					
						
							|  |  |  |                             "deleting any files." | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         named_args :installed_formula, min: 1
 | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2018-11-11 17:48:28 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-01 11:47:18 -07:00
										 |  |  |       sig { override.void } | 
					
						
							|  |  |  |       def run | 
					
						
							|  |  |  |         options = { dry_run: args.dry_run?, verbose: args.verbose? } | 
					
						
							| 
									
										
										
										
											2018-11-11 17:48:28 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-01 11:47:18 -07:00
										 |  |  |         args.named.to_default_kegs.each do |keg| | 
					
						
							|  |  |  |           if args.dry_run? | 
					
						
							|  |  |  |             puts "Would remove:" | 
					
						
							|  |  |  |             keg.unlink(**options) | 
					
						
							|  |  |  |             next | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2015-09-06 15:25:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-01 11:47:18 -07:00
										 |  |  |           Unlink.unlink(keg, dry_run: args.dry_run?, verbose: args.verbose?) | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2015-09-06 15:25:36 +08:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2010-09-11 20:22:54 +01:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |