2020-11-25 17:03:23 +01:00
|
|
|
# typed: true
|
2020-07-27 10:37:46 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "cli/parser"
|
|
|
|
require "utils/pypi"
|
|
|
|
|
|
|
|
module Homebrew
|
2020-10-20 12:03:48 +02:00
|
|
|
extend T::Sig
|
|
|
|
|
2020-07-27 10:37:46 -04:00
|
|
|
module_function
|
|
|
|
|
2020-10-20 12:03:48 +02:00
|
|
|
sig { returns(CLI::Parser) }
|
2020-07-27 10:37:46 -04:00
|
|
|
def update_python_resources_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
|
|
|
usage_banner <<~EOS
|
|
|
|
`update-python-resources` [<options>] <formula>
|
|
|
|
|
|
|
|
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."
|
|
|
|
switch "--ignore-non-pypi-packages",
|
|
|
|
description: "Don't fail if <formula> is not a PyPI package."
|
2020-11-12 10:40:41 -05:00
|
|
|
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."
|
2020-11-18 02:25:55 -05:00
|
|
|
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-11-12 10:40:41 -05:00
|
|
|
|
2020-07-27 10:37:46 -04:00
|
|
|
min_named :formula
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_python_resources
|
|
|
|
args = update_python_resources_args.parse
|
|
|
|
|
2020-08-19 10:34:48 -04:00
|
|
|
args.named.to_formulae.each do |formula|
|
2020-11-18 02:25:55 -05:00
|
|
|
PyPI.update_python_resources! formula,
|
|
|
|
version: args.version,
|
|
|
|
package_name: args.package_name,
|
|
|
|
extra_packages: args.extra_packages,
|
|
|
|
exclude_packages: args.exclude_packages,
|
|
|
|
print_only: args.print_only?,
|
|
|
|
silent: args.silent?,
|
2020-07-27 10:37:46 -04:00
|
|
|
ignore_non_pypi_packages: args.ignore_non_pypi_packages?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|