| 
									
										
										
										
											2024-03-21 22:10:12 -07:00
										 |  |  | # typed: strict | 
					
						
							| 
									
										
										
										
											2020-07-27 10:37:46 -04:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 22:10:12 -07:00
										 |  |  | require "abstract_command" | 
					
						
							| 
									
										
										
										
											2020-07-27 10:37:46 -04:00
										 |  |  | require "utils/pypi" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module Homebrew | 
					
						
							| 
									
										
										
										
											2024-03-21 22:10:12 -07:00
										 |  |  |   module DevCmd | 
					
						
							|  |  |  |     class UpdatePythonResources < AbstractCommand | 
					
						
							|  |  |  |       cmd_args do | 
					
						
							|  |  |  |         description <<~EOS | 
					
						
							|  |  |  |           Update versions for PyPI resource blocks in <formula>. | 
					
						
							|  |  |  |         EOS | 
					
						
							|  |  |  |         switch "-p", "--print-only", | 
					
						
							|  |  |  |                description: "Print the updated resource blocks instead of changing <formula>." | 
					
						
							|  |  |  |         switch "-s", "--silent", | 
					
						
							|  |  |  |                description: "Suppress any output." | 
					
						
							| 
									
										
										
										
											2025-02-06 21:20:55 +08:00
										 |  |  |         switch "--ignore-errors", | 
					
						
							|  |  |  |                description: "Record all discovered resources, even those that can't be resolved successfully. " \ | 
					
						
							|  |  |  |                             "This option is ignored for homebrew/core formulae." | 
					
						
							| 
									
										
										
										
											2024-03-21 22:10:12 -07:00
										 |  |  |         switch "--ignore-non-pypi-packages", | 
					
						
							|  |  |  |                description: "Don't fail if <formula> is not a PyPI package." | 
					
						
							|  |  |  |         switch "--install-dependencies", | 
					
						
							|  |  |  |                description: "Install missing dependencies required to update resources." | 
					
						
							|  |  |  |         flag   "--version=", | 
					
						
							|  |  |  |                description: "Use the specified <version> when finding resources for <formula>. " \ | 
					
						
							|  |  |  |                             "If no version is specified, the current version for <formula> will be used." | 
					
						
							|  |  |  |         flag   "--package-name=", | 
					
						
							|  |  |  |                description: "Use the specified <package-name> when finding resources for <formula>. " \ | 
					
						
							|  |  |  |                             "If no package name is specified, it will be inferred from the formula's stable URL." | 
					
						
							|  |  |  |         comma_array "--extra-packages", | 
					
						
							|  |  |  |                     description: "Include these additional packages when finding resources." | 
					
						
							|  |  |  |         comma_array "--exclude-packages", | 
					
						
							|  |  |  |                     description: "Exclude these packages when finding resources." | 
					
						
							| 
									
										
										
										
											2020-07-27 10:37:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 22:10:12 -07:00
										 |  |  |         named_args :formula, min: 1, without_api: true | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2020-11-12 10:40:41 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-21 22:10:12 -07:00
										 |  |  |       sig { override.void } | 
					
						
							|  |  |  |       def run | 
					
						
							|  |  |  |         args.named.to_formulae.each do |formula| | 
					
						
							| 
									
										
										
										
											2025-02-21 10:32:39 +08:00
										 |  |  |           ignore_errors = if formula.tap&.official? | 
					
						
							| 
									
										
										
										
											2025-02-06 21:20:55 +08:00
										 |  |  |             false | 
					
						
							|  |  |  |           else | 
					
						
							|  |  |  |             args.ignore_errors? | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2024-03-21 22:10:12 -07:00
										 |  |  |           PyPI.update_python_resources! formula, | 
					
						
							|  |  |  |                                         version:                  args.version, | 
					
						
							|  |  |  |                                         package_name:             args.package_name, | 
					
						
							|  |  |  |                                         extra_packages:           args.extra_packages, | 
					
						
							|  |  |  |                                         exclude_packages:         args.exclude_packages, | 
					
						
							|  |  |  |                                         install_dependencies:     args.install_dependencies?, | 
					
						
							|  |  |  |                                         print_only:               args.print_only?, | 
					
						
							|  |  |  |                                         silent:                   args.silent?, | 
					
						
							|  |  |  |                                         verbose:                  args.verbose?, | 
					
						
							| 
									
										
										
										
											2025-02-06 21:20:55 +08:00
										 |  |  |                                         ignore_errors:            ignore_errors, | 
					
						
							| 
									
										
										
										
											2024-03-21 22:10:12 -07:00
										 |  |  |                                         ignore_non_pypi_packages: args.ignore_non_pypi_packages? | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							| 
									
										
										
										
											2020-07-27 10:37:46 -04:00
										 |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |