| 
									
										
										
										
											2020-11-25 17:03:23 +01:00
										 |  |  | # typed: true | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-09 15:01:56 +03:00
										 |  |  | require "migrator" | 
					
						
							| 
									
										
										
										
											2019-04-17 18:25:08 +09:00
										 |  |  | require "cli/parser" | 
					
						
							| 
									
										
										
										
											2023-04-08 14:10:58 +02:00
										 |  |  | require "cask/migrator" | 
					
						
							| 
									
										
										
										
											2015-08-09 15:01:56 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2020-10-20 12:03:48 +02:00
										 |  |  |   sig { returns(CLI::Parser) } | 
					
						
							| 
									
										
										
										
											2023-04-08 14:10:58 +02:00
										 |  |  |   def self.migrate_args | 
					
						
							| 
									
										
										
										
											2018-11-05 12:46:57 +05:30
										 |  |  |     Homebrew::CLI::Parser.new do | 
					
						
							| 
									
										
										
										
											2021-01-15 15:04:02 -05:00
										 |  |  |       description <<~EOS | 
					
						
							| 
									
										
										
										
											2019-08-06 14:22:24 -04:00
										 |  |  |         Migrate renamed packages to new names, where <formula> are old names of | 
					
						
							| 
									
										
										
										
											2018-11-05 12:46:57 +05:30
										 |  |  |         packages. | 
					
						
							|  |  |  |       EOS | 
					
						
							| 
									
										
										
										
											2020-07-27 03:59:52 +02:00
										 |  |  |       switch "-f", "--force", | 
					
						
							| 
									
										
										
										
											2022-06-28 10:09:59 +01:00
										 |  |  |              description: "Treat installed <formula> and provided <formula> as if they are from " \ | 
					
						
							| 
									
										
										
										
											2019-08-06 14:22:24 -04:00
										 |  |  |                           "the same taps and migrate them anyway." | 
					
						
							| 
									
										
										
										
											2021-08-31 12:27:14 -04:00
										 |  |  |       switch "-n", "--dry-run", | 
					
						
							|  |  |  |              description: "Show what would be migrated, but do not actually migrate anything." | 
					
						
							| 
									
										
										
										
											2023-04-08 14:10:58 +02:00
										 |  |  |       switch "--formula", "--formulae", | 
					
						
							|  |  |  |              description: "Only migrate formulae." | 
					
						
							|  |  |  |       switch "--cask", "--casks", | 
					
						
							|  |  |  |              description: "Only migrate casks." | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       conflicts "--formula", "--cask" | 
					
						
							| 
									
										
										
										
											2020-07-30 18:40:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-08 14:10:58 +02:00
										 |  |  |       named_args [:installed_formula, :installed_cask], min: 1
 | 
					
						
							| 
									
										
										
										
											2018-11-05 12:46:57 +05:30
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-08 14:10:58 +02:00
										 |  |  |   def self.migrate | 
					
						
							| 
									
										
										
										
											2020-07-25 21:33:48 +02:00
										 |  |  |     args = migrate_args.parse | 
					
						
							| 
									
										
										
										
											2018-11-05 12:46:57 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-04-08 14:10:58 +02:00
										 |  |  |     args.named.to_formulae_and_casks(warn: false).each do |formula_or_cask| | 
					
						
							|  |  |  |       case formula_or_cask | 
					
						
							|  |  |  |       when Formula | 
					
						
							|  |  |  |         Migrator.migrate_if_needed(formula_or_cask, force: args.force?, dry_run: args.dry_run?) | 
					
						
							|  |  |  |       when Cask::Cask | 
					
						
							|  |  |  |         Cask::Migrator.migrate_if_needed(formula_or_cask, dry_run: args.dry_run?) | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2015-08-09 15:01:56 +03:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |