Merge branch 'master' into integrate-uses

This commit is contained in:
William Ma 2020-08-01 11:55:40 -04:00
commit 72c672b814
98 changed files with 823 additions and 563 deletions

3
.github/codecov.yml vendored
View File

@ -6,3 +6,6 @@ coverage:
project: project:
default: default:
threshold: 0.05% threshold: 0.05%
patch:
default:
informational: true

View File

@ -106,6 +106,9 @@ jobs:
# don't care about `brew cask style` here. # don't care about `brew cask style` here.
brew untap adoptopenjdk/openjdk brew untap adoptopenjdk/openjdk
# don't care about `brew audit` here.
brew untap mongodb/brew
else else
# Fix permissions for 'brew tests' # Fix permissions for 'brew tests'
sudo chmod -R g-w,o-w /home/linuxbrew /home/runner /opt sudo chmod -R g-w,o-w /home/linuxbrew /home/runner /opt
@ -166,6 +169,9 @@ jobs:
if: matrix.os == 'macOS-latest' if: matrix.os == 'macOS-latest'
run: brew cask style run: brew cask style
- name: Run brew audit
run: brew audit --skip-style
- name: Run vale for docs linting - name: Run vale for docs linting
run: | run: |
brew install vale brew install vale

3
.gitignore vendored
View File

@ -86,11 +86,13 @@
**/vendor/bundle/ruby/*/gems/byebug-*/ **/vendor/bundle/ruby/*/gems/byebug-*/
**/vendor/bundle/ruby/*/gems/coderay-*/ **/vendor/bundle/ruby/*/gems/coderay-*/
**/vendor/bundle/ruby/*/gems/colorize-*/ **/vendor/bundle/ruby/*/gems/colorize-*/
**/vendor/bundle/ruby/*/gems/commander-*/
**/vendor/bundle/ruby/*/gems/connection_pool-*/ **/vendor/bundle/ruby/*/gems/connection_pool-*/
**/vendor/bundle/ruby/*/gems/codecov-*/ **/vendor/bundle/ruby/*/gems/codecov-*/
**/vendor/bundle/ruby/*/gems/diff-lcs-*/ **/vendor/bundle/ruby/*/gems/diff-lcs-*/
**/vendor/bundle/ruby/*/gems/docile-*/ **/vendor/bundle/ruby/*/gems/docile-*/
**/vendor/bundle/ruby/*/gems/domain_name-*/ **/vendor/bundle/ruby/*/gems/domain_name-*/
**/vendor/bundle/ruby/*/gems/highline-*/
**/vendor/bundle/ruby/*/gems/http-cookie-*/ **/vendor/bundle/ruby/*/gems/http-cookie-*/
**/vendor/bundle/ruby/*/gems/hpricot-*/ **/vendor/bundle/ruby/*/gems/hpricot-*/
**/vendor/bundle/ruby/*/gems/jaro_winkler-*/ **/vendor/bundle/ruby/*/gems/jaro_winkler-*/
@ -107,6 +109,7 @@
**/vendor/bundle/ruby/*/gems/ntlm-http-*/ **/vendor/bundle/ruby/*/gems/ntlm-http-*/
**/vendor/bundle/ruby/*/gems/parallel-*/ **/vendor/bundle/ruby/*/gems/parallel-*/
**/vendor/bundle/ruby/*/gems/parallel_tests-*/ **/vendor/bundle/ruby/*/gems/parallel_tests-*/
**/vendor/bundle/ruby/*/gems/parlour-*/
**/vendor/bundle/ruby/*/gems/parser-*/ **/vendor/bundle/ruby/*/gems/parser-*/
**/vendor/bundle/ruby/*/gems/powerpack-*/ **/vendor/bundle/ruby/*/gems/powerpack-*/
**/vendor/bundle/ruby/*/gems/psych-*/ **/vendor/bundle/ruby/*/gems/psych-*/

View File

@ -181,7 +181,9 @@ Layout/LineLength:
Max: 118 Max: 118
# ignore manpage comments and long single-line strings # ignore manpage comments and long single-line strings
IgnoredPatterns: ['#: ', ' url "', ' mirror "', ' plist_options ', IgnoredPatterns: ['#: ', ' url "', ' mirror "', ' plist_options ',
' appcast "', ' executable: "', '#{version.', ' appcast "', ' executable: "', ' font "', ' homepage "', ' name "',
' pkg "', ' pkgutil: "', '#{language}', '#{version.',
' "/Library/Application Support/', '"/Library/Caches/', '"/Library/PreferencePanes/',
' "~/Library/Application Support/', '"~/Library/Caches/', '"~/Application Support', ' "~/Library/Application Support/', '"~/Library/Caches/', '"~/Application Support',
' was verified as official when first introduced to the cask'] ' was verified as official when first introduced to the cask']

View File

@ -41,6 +41,7 @@ begin
empty_argv = ARGV.empty? empty_argv = ARGV.empty?
help_flag_list = %w[-h --help --usage -?] help_flag_list = %w[-h --help --usage -?]
help_flag = !ENV["HOMEBREW_HELP"].nil? help_flag = !ENV["HOMEBREW_HELP"].nil?
help_cmd_index = nil
cmd = nil cmd = nil
ARGV.each_with_index do |arg, i| ARGV.each_with_index do |arg, i|
@ -49,12 +50,17 @@ begin
if arg == "help" && !cmd if arg == "help" && !cmd
# Command-style help: `help <cmd>` is fine, but `<cmd> help` is not. # Command-style help: `help <cmd>` is fine, but `<cmd> help` is not.
help_flag = true help_flag = true
help_cmd_index = i
elsif !cmd && !help_flag_list.include?(arg) elsif !cmd && !help_flag_list.include?(arg)
cmd = ARGV.delete_at(i) cmd = ARGV.delete_at(i)
cmd = Commands::HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd) cmd = Commands::HOMEBREW_INTERNAL_COMMAND_ALIASES.fetch(cmd, cmd)
end end
end end
ARGV.delete_at(help_cmd_index) if help_cmd_index
Homebrew.args = Homebrew::CLI::Parser.new.parse(ARGV.dup.freeze, ignore_invalid_options: true)
path = PATH.new(ENV["PATH"]) path = PATH.new(ENV["PATH"])
homebrew_path = PATH.new(ENV["HOMEBREW_PATH"]) homebrew_path = PATH.new(ENV["HOMEBREW_PATH"])
@ -117,7 +123,7 @@ begin
odie "Unknown command: #{cmd}" if !possible_tap || possible_tap.installed? odie "Unknown command: #{cmd}" if !possible_tap || possible_tap.installed?
# Unset HOMEBREW_HELP to avoid confusing the tap # Unset HOMEBREW_HELP to avoid confusing the tap
ENV.delete("HOMEBREW_HELP") if help_flag with_env HOMEBREW_HELP: nil do
tap_commands = [] tap_commands = []
cgroup = Utils.popen_read("cat", "/proc/1/cgroup") cgroup = Utils.popen_read("cat", "/proc/1/cgroup")
if %w[azpl_job actions_job docker garden kubepods].none? { |container| cgroup.include?(container) } if %w[azpl_job actions_job docker garden kubepods].none? { |container| cgroup.include?(container) }
@ -126,7 +132,8 @@ begin
end end
tap_commands += %W[#{HOMEBREW_BREW_FILE} tap #{possible_tap.name}] tap_commands += %W[#{HOMEBREW_BREW_FILE} tap #{possible_tap.name}]
safe_system(*tap_commands) safe_system(*tap_commands)
ENV["HOMEBREW_HELP"] = "1" if help_flag end
exec HOMEBREW_BREW_FILE, cmd, *ARGV exec HOMEBREW_BREW_FILE, cmd, *ARGV
end end
rescue UsageError => e rescue UsageError => e

View File

@ -336,6 +336,8 @@ fi
for arg in "$@" for arg in "$@"
do do
[[ $arg = "--" ]] && break
if [[ $arg = "--help" || $arg = "-h" || $arg = "--usage" || $arg = "-?" ]] if [[ $arg = "--help" || $arg = "-h" || $arg = "--usage" || $arg = "-?" ]]
then then
export HOMEBREW_HELP="1" export HOMEBREW_HELP="1"

View File

@ -47,7 +47,7 @@ module Cask
upgradable_casks.each do |(old_cask, new_cask)| upgradable_casks.each do |(old_cask, new_cask)|
upgrade_cask(old_cask, new_cask) upgrade_cask(old_cask, new_cask)
rescue => e rescue => e
caught_exceptions << e caught_exceptions << e.exception("#{new_cask.full_name}: #{e}")
next next
end end

View File

@ -10,26 +10,21 @@ module Homebrew
# undefine tap to allow --tap argument # undefine tap to allow --tap argument
undef tap undef tap
def initialize(argv = ARGV.freeze, set_default_args: false) def initialize
super() super()
@processed_options = [] @processed_options = []
@options_only = args_options_only(argv) @options_only = []
@flags_only = args_flags_only(argv) @flags_only = []
# Can set these because they will be overwritten by freeze_named_args! # Can set these because they will be overwritten by freeze_named_args!
# (whereas other values below will only be overwritten if passed). # (whereas other values below will only be overwritten if passed).
self[:named_args] = argv.reject { |arg| arg.start_with?("-") } self[:named_args] = []
self[:remaining] = []
end
# Set values needed before Parser#parse has been run. def freeze_remaining_args!(remaining_args)
return unless set_default_args self[:remaining] = remaining_args.freeze
self[:build_from_source?] = argv.include?("--build-from-source") || argv.include?("-s")
self[:build_bottle?] = argv.include?("--build-bottle")
self[:force_bottle?] = argv.include?("--force-bottle")
self[:HEAD?] = argv.include?("--HEAD")
self[:devel?] = argv.include?("--devel")
self[:universal?] = argv.include?("--universal")
end end
def freeze_named_args!(named_args) def freeze_named_args!(named_args)
@ -43,8 +38,7 @@ module Homebrew
@kegs = nil @kegs = nil
@kegs_casks = nil @kegs_casks = nil
self[:named_args] = named_args self[:named_args] = named_args.freeze
self[:named_args].freeze
end end
def freeze_processed_options!(processed_options) def freeze_processed_options!(processed_options)
@ -54,12 +48,8 @@ module Homebrew
@processed_options += processed_options @processed_options += processed_options
@processed_options.freeze @processed_options.freeze
@options_only = args_options_only(cli_args) @options_only = cli_args.select { |a| a.start_with?("-") }.freeze
@flags_only = args_flags_only(cli_args) @flags_only = cli_args.select { |a| a.start_with?("--") }.freeze
end
def passthrough
options_only - CLI::Parser.global_options.values.map(&:first).flatten
end end
def named def named
@ -219,16 +209,6 @@ module Homebrew
@cli_args.freeze @cli_args.freeze
end end
def args_options_only(args)
args.select { |arg| arg.start_with?("-") }
.freeze
end
def args_flags_only(args)
args.select { |arg| arg.start_with?("--") }
.freeze
end
def downcased_unique_named def downcased_unique_named
# Only lowercase names, not paths, bottle filenames or URLs # Only lowercase names, not paths, bottle filenames or URLs
named.map do |arg| named.map do |arg|

View File

@ -13,10 +13,6 @@ module Homebrew
class Parser class Parser
attr_reader :processed_options, :hide_from_man_page attr_reader :processed_options, :hide_from_man_page
def self.parse(argv = ARGV.freeze, allow_no_named_args: false, &block)
new(argv, &block).parse(allow_no_named_args: allow_no_named_args)
end
def self.from_cmd_path(cmd_path) def self.from_cmd_path(cmd_path)
cmd_args_method_name = Commands.args_method_name(cmd_path) cmd_args_method_name = Commands.args_method_name(cmd_path)
@ -30,17 +26,17 @@ module Homebrew
end end
def self.global_options def self.global_options
{ [
quiet: [["-q", "--quiet"], :quiet, "Suppress any warnings."], ["-q", "--quiet", "Suppress any warnings."],
verbose: [["-v", "--verbose"], :verbose, "Make some output more verbose."], ["-v", "--verbose", "Make some output more verbose."],
debug: [["-d", "--debug"], :debug, "Display any debugging information."], ["-d", "--debug", "Display any debugging information."],
} ]
end end
def initialize(argv = ARGV.freeze, &block) def initialize(&block)
@parser = OptionParser.new @parser = OptionParser.new
@argv = argv
@args = Homebrew::CLI::Args.new(@argv) @args = Homebrew::CLI::Args.new
@constraints = [] @constraints = []
@conflicts = [] @conflicts = []
@ -50,25 +46,32 @@ module Homebrew
@min_named_args = nil @min_named_args = nil
@min_named_type = nil @min_named_type = nil
@hide_from_man_page = false @hide_from_man_page = false
instance_eval(&block) @formula_options = false
self.class.global_options.each do |short, long, desc|
switch short, long, description: desc
end
instance_eval(&block) if block_given?
post_initialize post_initialize
end end
def post_initialize def post_initialize
# Disable default handling of `--version` switch.
@parser.base.long.delete("version")
# Disable default handling of `--help` switch.
@parser.on_tail("-h", "--help", "Show this message.") do @parser.on_tail("-h", "--help", "Show this message.") do
puts generate_help_text # Handled in `brew.rb`.
exit 0
end end
end end
def switch(*names, description: nil, env: nil, required_for: nil, depends_on: nil) def switch(*names, description: nil, env: nil, required_for: nil, depends_on: nil)
global_switch = names.first.is_a?(Symbol) global_switch = names.first.is_a?(Symbol)
names, env, default_description = common_switch(*names) if global_switch return if global_switch
if description.nil? && global_switch
description = default_description description = option_to_description(*names) if description.nil?
elsif description.nil?
description = option_to_description(*names)
end
process_option(*names, description) process_option(*names, description)
@parser.on(*names, *wrap_option_desc(description)) do @parser.on(*names, *wrap_option_desc(description)) do
enable_switch(*names, from: :args) enable_switch(*names, from: :args)
@ -153,42 +156,51 @@ module Homebrew
@parser.to_s @parser.to_s
end end
def parse(argv = @argv, allow_no_named_args: false) def parse_remaining(argv, ignore_invalid_options: false)
i = 0
remaining = []
argv, non_options = split_non_options(argv)
while i < argv.count
begin
begin
arg = argv[i]
remaining << arg unless @parser.parse([arg]).empty?
rescue OptionParser::MissingArgument
raise if i + 1 >= argv.count
args = argv[i..(i + 1)]
@parser.parse(args)
i += 1
end
rescue OptionParser::InvalidOption
if ignore_invalid_options
remaining << arg
else
$stderr.puts generate_help_text
raise
end
end
i += 1
end
[remaining, non_options]
end
def parse(argv = ARGV.freeze, ignore_invalid_options: false)
raise "Arguments were already parsed!" if @args_parsed raise "Arguments were already parsed!" if @args_parsed
begin # If we accept formula options, parse once allowing invalid options
named_args = @parser.parse(argv) # so we can get the remaining list containing formula names.
rescue OptionParser::InvalidOption => e if @formula_options
$stderr.puts generate_help_text remaining, non_options = parse_remaining(argv, ignore_invalid_options: true)
raise e
end
check_constraint_violations argv = [*remaining, "--", *non_options]
check_named_args(named_args, allow_no_named_args: allow_no_named_args)
@args.freeze_named_args!(named_args)
@args.freeze_processed_options!(@processed_options)
Homebrew.args = @args
@args_parsed = true formulae(argv).each do |f|
@args
end
def global_option?(name, desc)
Homebrew::CLI::Parser.global_options.key?(name.to_sym) &&
Homebrew::CLI::Parser.global_options[name.to_sym].last == desc
end
def generate_help_text
@parser.to_s
.sub(/^/, "#{Tty.bold}Usage: brew#{Tty.reset} ")
.gsub(/`(.*?)`/m, "#{Tty.bold}\\1#{Tty.reset}")
.gsub(%r{<([^\s]+?://[^\s]+?)>}) { |url| Formatter.url(url) }
.gsub(/<(.*?)>/m, "#{Tty.underline}\\1#{Tty.reset}")
.gsub(/\*(.*?)\*/m, "#{Tty.underline}\\1#{Tty.reset}")
end
def formula_options
formulae.each do |f|
next if f.options.empty? next if f.options.empty?
f.options.each do |o| f.options.each do |o|
@ -201,8 +213,37 @@ module Homebrew
end end
end end
end end
rescue FormulaUnavailableError end
remaining, non_options = parse_remaining(argv, ignore_invalid_options: ignore_invalid_options)
named_args = if ignore_invalid_options
[] []
else
remaining + non_options
end
check_constraint_violations unless ignore_invalid_options
check_named_args(named_args) unless ignore_invalid_options
@args.freeze_named_args!(named_args)
@args.freeze_remaining_args!(non_options.empty? ? remaining : [*remaining, "--", non_options])
@args.freeze_processed_options!(@processed_options)
@args_parsed = true
@args
end
def generate_help_text
@parser.to_s
.sub(/^/, "#{Tty.bold}Usage: brew#{Tty.reset} ")
.gsub(/`(.*?)`/m, "#{Tty.bold}\\1#{Tty.reset}")
.gsub(%r{<([^\s]+?://[^\s]+?)>}) { |url| Formatter.url(url) }
.gsub(/<(.*?)>/m, "#{Tty.underline}\\1#{Tty.reset}")
.gsub(/\*(.*?)\*/m, "#{Tty.underline}\\1#{Tty.reset}")
end
def formula_options
@formula_options = true
end end
def max_named(count) def max_named(count)
@ -256,11 +297,6 @@ module Homebrew
end end
end end
# These are common/global switches accessible throughout Homebrew
def common_switch(name)
Homebrew::CLI::Parser.global_options.fetch(name, name)
end
def option_passed?(name) def option_passed?(name)
@args[name.to_sym] || @args["#{name}?".to_sym] @args[name.to_sym] || @args["#{name}?".to_sym]
end end
@ -328,8 +364,10 @@ module Homebrew
check_constraints check_constraints
end end
def check_named_args(args, allow_no_named_args: false) def check_named_args(args)
min_exception = case @min_named_type min_exception = case @min_named_type
when :cask
Cask::CaskUnspecifiedError.new
when :formula when :formula
FormulaUnspecifiedError.new FormulaUnspecifiedError.new
when :keg when :keg
@ -337,8 +375,8 @@ module Homebrew
else else
MinNamedArgumentsError.new(@min_named_args) MinNamedArgumentsError.new(@min_named_args)
end end
raise min_exception if !allow_no_named_args && !@min_named_args.nil? && args.size < @min_named_args raise min_exception if @min_named_args && args.size < @min_named_args
raise MaxNamedArgumentsError, @max_named_args if !@max_named_args.nil? && args.size > @max_named_args raise MaxNamedArgumentsError, @max_named_args if @max_named_args && args.size > @max_named_args
end end
def process_option(*args) def process_option(*args)
@ -346,11 +384,21 @@ module Homebrew
@processed_options << [option.short.first, option.long.first, option.arg, option.desc.first] @processed_options << [option.short.first, option.long.first, option.arg, option.desc.first]
end end
def formulae def split_non_options(argv)
named_args = @argv.reject { |arg| arg.start_with?("-") } if sep = argv.index("--")
spec = if @argv.include?("--HEAD") [argv.take(sep), argv.drop(sep + 1)]
else
[argv, []]
end
end
def formulae(argv)
argv, non_options = split_non_options(argv)
named_args = argv.reject { |arg| arg.start_with?("-") } + non_options
spec = if argv.include?("--HEAD")
:head :head
elsif @argv.include?("--devel") elsif argv.include?("--devel")
:devel :devel
else else
:stable :stable
@ -360,7 +408,11 @@ module Homebrew
named_args.map do |arg| named_args.map do |arg|
next if arg.match?(HOMEBREW_CASK_TAP_CASK_REGEX) next if arg.match?(HOMEBREW_CASK_TAP_CASK_REGEX)
Formulary.factory(arg, spec, flags: @args.flags_only) begin
Formulary.factory(arg, spec, flags: argv.select { |a| a.start_with?("--") })
rescue FormulaUnavailableError
nil
end
end.compact.uniq(&:name) end.compact.uniq(&:name)
end end
end end

View File

@ -20,7 +20,7 @@ module Homebrew
end end
def __cellar def __cellar
__cellar_args.parse args = __cellar_args.parse
if args.no_named? if args.no_named?
puts HOMEBREW_CELLAR puts HOMEBREW_CELLAR

View File

@ -20,7 +20,7 @@ module Homebrew
end end
def __prefix def __prefix
__prefix_args.parse args = __prefix_args.parse
if args.no_named? if args.no_named?
puts HOMEBREW_PREFIX puts HOMEBREW_PREFIX

View File

@ -18,7 +18,7 @@ module Homebrew
end end
def __repository def __repository
__repository_args.parse args = __repository_args.parse
if args.no_named? if args.no_named?
puts HOMEBREW_REPOSITORY puts HOMEBREW_REPOSITORY

View File

@ -22,14 +22,12 @@ module Homebrew
`brew analytics regenerate-uuid`: `brew analytics regenerate-uuid`:
Regenerate the UUID used for Homebrew's analytics. Regenerate the UUID used for Homebrew's analytics.
EOS EOS
switch :verbose
switch :debug
max_named 1 max_named 1
end end
end end
def analytics def analytics
analytics_args.parse args = analytics_args.parse
case args.named.first case args.named.first
when nil, "state" when nil, "state"

View File

@ -27,13 +27,11 @@ module Homebrew
"If you want to delete those too: `rm -rf \"$(brew --cache)\"`" "If you want to delete those too: `rm -rf \"$(brew --cache)\"`"
switch "--prune-prefix", switch "--prune-prefix",
description: "Only prune the symlinks and directories from the prefix and remove no other files." description: "Only prune the symlinks and directories from the prefix and remove no other files."
switch :verbose
switch :debug
end end
end end
def cleanup def cleanup
cleanup_args.parse args = cleanup_args.parse
cleanup = Cleanup.new(*args.named, dry_run: args.dry_run?, scrub: args.s?, days: args.prune&.to_i) cleanup = Cleanup.new(*args.named, dry_run: args.dry_run?, scrub: args.s?, days: args.prune&.to_i)
if args.prune_prefix? if args.prune_prefix?

View File

@ -12,19 +12,18 @@ module Homebrew
Show lists of built-in and external commands. Show lists of built-in and external commands.
EOS EOS
switch :quiet, switch "-q", "--quiet",
description: "List only the names of commands without category headers." description: "List only the names of commands without category headers."
switch "--include-aliases", switch "--include-aliases",
depends_on: "--quiet", depends_on: "--quiet",
description: "Include aliases of internal commands." description: "Include aliases of internal commands."
switch :verbose
switch :debug
max_named 0 max_named 0
end end
end end
def commands def commands
commands_args.parse args = commands_args.parse
if args.quiet? if args.quiet?
puts Formatter.columns(Commands.commands(aliases: args.include_aliases?)) puts Formatter.columns(Commands.commands(aliases: args.include_aliases?))

View File

@ -14,8 +14,7 @@ module Homebrew
Show Homebrew and system configuration info useful for debugging. If you file Show Homebrew and system configuration info useful for debugging. If you file
a bug report, you will be required to provide this information. a bug report, you will be required to provide this information.
EOS EOS
switch :verbose
switch :debug
max_named 0 max_named 0
end end
end end

View File

@ -53,15 +53,14 @@ module Homebrew
description: "Switch into the mode used by the `--all` option, but only list dependencies "\ description: "Switch into the mode used by the `--all` option, but only list dependencies "\
"for each provided <formula>, one formula per line. This is used for "\ "for each provided <formula>, one formula per line. This is used for "\
"debugging the `--installed`/`--all` display mode." "debugging the `--installed`/`--all` display mode."
switch :verbose
switch :debug
conflicts "--installed", "--all" conflicts "--installed", "--all"
formula_options formula_options
end end
end end
def deps def deps
deps_args.parse args = deps_args.parse
Formulary.enable_factory_cache! Formulary.enable_factory_cache!
@ -84,13 +83,13 @@ module Homebrew
raise FormulaUnspecifiedError raise FormulaUnspecifiedError
end end
puts_deps_tree dependents, recursive puts_deps_tree dependents, recursive, args: args
return return
elsif args.all? elsif args.all?
puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive, args: args
return return
elsif !args.no_named? && args.for_each? elsif !args.no_named? && args.for_each?
puts_deps sorted_dependents(args.formulae_and_casks), recursive puts_deps sorted_dependents(args.formulae_and_casks), recursive, args: args
return return
end end
@ -103,9 +102,9 @@ module Homebrew
dependents = dependents(args.formulae_and_casks) dependents = dependents(args.formulae_and_casks)
all_deps = deps_for_dependents(dependents, recursive, &(args.union? ? :| : :&)) all_deps = deps_for_dependents(dependents, recursive, args: args, &(args.union? ? :| : :&))
condense_requirements(all_deps) condense_requirements(all_deps)
all_deps.map!(&method(:dep_display_name)) all_deps.map! { |d| dep_display_name(d, args: args) }
all_deps.uniq! all_deps.uniq!
all_deps.sort! unless args.n? all_deps.sort! unless args.n?
puts all_deps puts all_deps
@ -120,7 +119,7 @@ module Homebrew
deps.select! { |dep| dep.is_a?(Requirement) || dep.installed? } if args.installed? deps.select! { |dep| dep.is_a?(Requirement) || dep.installed? } if args.installed?
end end
def dep_display_name(dep) def dep_display_name(dep, args:)
str = if dep.is_a? Requirement str = if dep.is_a? Requirement
if args.include_requirements? if args.include_requirements?
":#{dep.display_s}" ":#{dep.display_s}"
@ -145,8 +144,8 @@ module Homebrew
str str
end end
def deps_for_dependent(d, recursive = false) def deps_for_dependent(d, recursive = false, args:)
includes, ignores = argv_includes_ignores(ARGV) includes, ignores = args_includes_ignores(args)
deps = d.runtime_dependencies if @use_runtime_dependencies deps = d.runtime_dependencies if @use_runtime_dependencies
@ -161,31 +160,31 @@ module Homebrew
deps + reqs.to_a deps + reqs.to_a
end end
def deps_for_dependents(dependents, recursive = false, &block) def deps_for_dependents(dependents, recursive = false, args:, &block)
dependents.map { |d| deps_for_dependent(d, recursive) }.reduce(&block) dependents.map { |d| deps_for_dependent(d, recursive, args: args) }.reduce(&block)
end end
def puts_deps(dependents, recursive = false) def puts_deps(dependents, recursive = false, args:)
dependents.each do |d| dependents.each do |dependent|
deps = deps_for_dependent(d, recursive) deps = deps_for_dependent(dependent, recursive, args: args)
condense_requirements(deps) condense_requirements(deps)
deps.sort_by!(&:name) deps.sort_by!(&:name)
deps.map!(&method(:dep_display_name)) deps.map! { |d| dep_display_name(d, args: args) }
puts "#{d.full_name}: #{deps.join(" ")}" puts "#{dependent.full_name}: #{deps.join(" ")}"
end end
end end
def puts_deps_tree(dependents, recursive = false) def puts_deps_tree(dependents, recursive = false, args:)
dependents.each do |d| dependents.each do |d|
puts d.full_name puts d.full_name
@dep_stack = [] @dep_stack = []
recursive_deps_tree(d, "", recursive) recursive_deps_tree(d, "", recursive, args: args)
puts puts
end end
end end
def recursive_deps_tree(f, prefix, recursive) def recursive_deps_tree(f, prefix, recursive, args:)
includes, ignores = argv_includes_ignores(ARGV) includes, ignores = args_includes_ignores(args)
dependables = @use_runtime_dependencies ? f.runtime_dependencies : f.deps dependables = @use_runtime_dependencies ? f.runtime_dependencies : f.deps
deps = reject_ignores(dependables, ignores, includes) deps = reject_ignores(dependables, ignores, includes)
reqs = reject_ignores(f.requirements, ignores, includes) reqs = reject_ignores(f.requirements, ignores, includes)
@ -202,7 +201,7 @@ module Homebrew
"├──" "├──"
end end
display_s = "#{tree_lines} #{dep_display_name(dep)}" display_s = "#{tree_lines} #{dep_display_name(dep, args: args)}"
is_circular = @dep_stack.include?(dep.name) is_circular = @dep_stack.include?(dep.name)
display_s = "#{display_s} (CIRCULAR DEPENDENCY)" if is_circular display_s = "#{display_s} (CIRCULAR DEPENDENCY)" if is_circular
puts "#{prefix}#{display_s}" puts "#{prefix}#{display_s}"
@ -215,7 +214,9 @@ module Homebrew
"" ""
end end
recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_addition, true) if dep.is_a? Dependency if dep.is_a? Dependency
recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_addition, true, args: args)
end
end end
@dep_stack.pop @dep_stack.pop

View File

@ -28,14 +28,14 @@ module Homebrew
switch "-d", "--description", switch "-d", "--description",
description: "Search just descriptions for <text>. If <text> is flanked by slashes, "\ description: "Search just descriptions for <text>. If <text> is flanked by slashes, "\
"it is interpreted as a regular expression." "it is interpreted as a regular expression."
switch :verbose
conflicts "--search", "--name", "--description" conflicts "--search", "--name", "--description"
min_named 1 min_named 1
end end
end end
def desc def desc
desc_args.parse args = desc_args.parse
search_type = if args.search? search_type = if args.search?
:either :either

View File

@ -23,13 +23,11 @@ module Homebrew
"if provided as arguments." "if provided as arguments."
switch "-D", "--audit-debug", switch "-D", "--audit-debug",
description: "Enable debugging and profiling of audit methods." description: "Enable debugging and profiling of audit methods."
switch :verbose
switch :debug
end end
end end
def doctor def doctor
doctor_args.parse args = doctor_args.parse
inject_dump_stats!(Diagnostic::Checks, /^check_*/) if args.audit_debug? inject_dump_stats!(Diagnostic::Checks, /^check_*/) if args.audit_debug?

View File

@ -23,7 +23,7 @@ module Homebrew
description: "Fetch development version instead of stable version." description: "Fetch development version instead of stable version."
switch "-f", "--force", switch "-f", "--force",
description: "Remove a previously cached version and re-fetch." description: "Remove a previously cached version and re-fetch."
switch :verbose, switch "-v", "--verbose",
description: "Do a verbose VCS checkout, if the URL represents a VCS. This is useful for "\ description: "Do a verbose VCS checkout, if the URL represents a VCS. This is useful for "\
"seeing if an existing VCS cache has been updated." "seeing if an existing VCS cache has been updated."
switch "--retry", switch "--retry",
@ -38,7 +38,7 @@ module Homebrew
switch "--force-bottle", switch "--force-bottle",
description: "Download a bottle if it exists for the current or newest version of macOS, "\ description: "Download a bottle if it exists for the current or newest version of macOS, "\
"even if it would not be used during installation." "even if it would not be used during installation."
switch :debug
conflicts "--devel", "--HEAD" conflicts "--devel", "--HEAD"
conflicts "--build-from-source", "--build-bottle", "--force-bottle" conflicts "--build-from-source", "--build-bottle", "--force-bottle"
min_named :formula min_named :formula
@ -66,7 +66,7 @@ module Homebrew
fetched_bottle = false fetched_bottle = false
if fetch_bottle?(f, args: args) if fetch_bottle?(f, args: args)
begin begin
fetch_formula(f.bottle) fetch_formula(f.bottle, args: args)
rescue Interrupt rescue Interrupt
raise raise
rescue => e rescue => e
@ -82,40 +82,40 @@ module Homebrew
next if fetched_bottle next if fetched_bottle
fetch_formula(f) fetch_formula(f, args: args)
f.resources.each do |r| f.resources.each do |r|
fetch_resource(r) fetch_resource(r, args: args)
r.patches.each { |p| fetch_patch(p) if p.external? } r.patches.each { |p| fetch_patch(p, args: args) if p.external? }
end end
f.patchlist.each { |p| fetch_patch(p) if p.external? } f.patchlist.each { |p| fetch_patch(p, args: args) if p.external? }
end end
end end
def fetch_resource(r) def fetch_resource(r, args:)
puts "Resource: #{r.name}" puts "Resource: #{r.name}"
fetch_fetchable r fetch_fetchable r, args: args
rescue ChecksumMismatchError => e rescue ChecksumMismatchError => e
retry if retry_fetch? r retry if retry_fetch?(r, args: args)
opoo "Resource #{r.name} reports different #{e.hash_type}: #{e.expected}" opoo "Resource #{r.name} reports different #{e.hash_type}: #{e.expected}"
end end
def fetch_formula(f) def fetch_formula(f, args:)
fetch_fetchable f fetch_fetchable f, args: args
rescue ChecksumMismatchError => e rescue ChecksumMismatchError => e
retry if retry_fetch? f retry if retry_fetch?(f, args: args)
opoo "Formula reports different #{e.hash_type}: #{e.expected}" opoo "Formula reports different #{e.hash_type}: #{e.expected}"
end end
def fetch_patch(p) def fetch_patch(p, args:)
fetch_fetchable p fetch_fetchable p, args: args
rescue ChecksumMismatchError => e rescue ChecksumMismatchError => e
Homebrew.failed = true Homebrew.failed = true
opoo "Patch reports different #{e.hash_type}: #{e.expected}" opoo "Patch reports different #{e.hash_type}: #{e.expected}"
end end
def retry_fetch?(f) def retry_fetch?(f, args:)
@fetch_failed ||= Set.new @fetch_failed ||= Set.new
if args.retry? && @fetch_failed.add?(f) if args.retry? && @fetch_failed.add?(f)
ohai "Retrying download" ohai "Retrying download"
@ -127,7 +127,7 @@ module Homebrew
end end
end end
def fetch_fetchable(f) def fetch_fetchable(f, args:)
f.clear_cache if args.force? f.clear_cache if args.force?
already_fetched = f.cached_download.exist? already_fetched = f.cached_download.exist?
@ -135,7 +135,7 @@ module Homebrew
begin begin
download = f.fetch(verify_download_integrity: false) download = f.fetch(verify_download_integrity: false)
rescue DownloadError rescue DownloadError
retry if retry_fetch? f retry if retry_fetch?(f, args: args)
raise raise
end end

View File

@ -28,13 +28,12 @@ module Homebrew
switch "-p", "--private", switch "-p", "--private",
description: "The Gist will be marked private and will not appear in listings but will "\ description: "The Gist will be marked private and will not appear in listings but will "\
"be accessible with its link." "be accessible with its link."
switch :verbose
switch :debug
named :formula named :formula
end end
end end
def gistify_logs(f) def gistify_logs(f, args:)
files = load_logs(f.logs) files = load_logs(f.logs)
build_time = f.logs.ctime build_time = f.logs.ctime
timestamp = build_time.strftime("%Y-%m-%d_%H-%M-%S") timestamp = build_time.strftime("%Y-%m-%d_%H-%M-%S")
@ -42,7 +41,7 @@ module Homebrew
s = StringIO.new s = StringIO.new
SystemConfig.dump_verbose_config s SystemConfig.dump_verbose_config s
# Dummy summary file, asciibetically first, to control display title of gist # Dummy summary file, asciibetically first, to control display title of gist
files["# #{f.name} - #{timestamp}.txt"] = { content: brief_build_info(f) } files["# #{f.name} - #{timestamp}.txt"] = { content: brief_build_info(f, with_hostname: args.with_hostname?) }
files["00.config.out"] = { content: s.string } files["00.config.out"] = { content: s.string }
files["00.doctor.out"] = { content: Utils.popen_read("#{HOMEBREW_PREFIX}/bin/brew", "doctor", err: :out) } files["00.doctor.out"] = { content: Utils.popen_read("#{HOMEBREW_PREFIX}/bin/brew", "doctor", err: :out) }
unless f.core_formula? unless f.core_formula?
@ -70,19 +69,19 @@ module Homebrew
else else
"#{f.name} (#{f.full_name}) on #{OS_VERSION} - Homebrew build logs" "#{f.name} (#{f.full_name}) on #{OS_VERSION} - Homebrew build logs"
end end
url = create_gist(files, descr) url = create_gist(files, descr, private: args.private?)
url = create_issue(f.tap, "#{f.name} failed to build on #{MacOS.full_version}", url) if args.new_issue? url = create_issue(f.tap, "#{f.name} failed to build on #{MacOS.full_version}", url) if args.new_issue?
puts url if url puts url if url
end end
def brief_build_info(f) def brief_build_info(f, with_hostname:)
build_time_str = f.logs.ctime.strftime("%Y-%m-%d %H:%M:%S") build_time_str = f.logs.ctime.strftime("%Y-%m-%d %H:%M:%S")
s = +<<~EOS s = +<<~EOS
Homebrew build logs for #{f.full_name} on #{OS_VERSION} Homebrew build logs for #{f.full_name} on #{OS_VERSION}
EOS EOS
if args.with_hostname? if with_hostname
hostname = Socket.gethostname hostname = Socket.gethostname
s << "Host: #{hostname}\n" s << "Host: #{hostname}\n"
end end
@ -123,13 +122,9 @@ module Homebrew
logs logs
end end
def create_private? def create_gist(files, description, private:)
args.private?
end
def create_gist(files, description)
url = "https://api.github.com/gists" url = "https://api.github.com/gists"
data = { "public" => !create_private?, "files" => files, "description" => description } data = { "public" => !private, "files" => files, "description" => description }
scopes = GitHub::CREATE_GIST_SCOPES scopes = GitHub::CREATE_GIST_SCOPES
GitHub.open_api(url, data: data, scopes: scopes)["html_url"] GitHub.open_api(url, data: data, scopes: scopes)["html_url"]
end end
@ -142,10 +137,10 @@ module Homebrew
end end
def gist_logs def gist_logs
gist_logs_args.parse args = gist_logs_args.parse
Install.perform_preinstall_checks(all_fatal: true) Install.perform_preinstall_checks(all_fatal: true)
Install.perform_build_from_source_checks(all_fatal: true) Install.perform_build_from_source_checks(all_fatal: true)
gistify_logs(args.resolved_formulae.first) gistify_logs(args.resolved_formulae.first, args: args)
end end
end end

View File

@ -15,12 +15,11 @@ module Homebrew
Open <formula>'s homepage in a browser, or open Homebrew's own homepage Open <formula>'s homepage in a browser, or open Homebrew's own homepage
if no formula is provided. if no formula is provided.
EOS EOS
switch :debug
end end
end end
def home def home
home_args.parse args = home_args.parse
if args.no_named? if args.no_named?
exec_browser HOMEBREW_WWW exec_browser HOMEBREW_WWW

View File

@ -52,15 +52,15 @@ module Homebrew
switch "--all", switch "--all",
depends_on: "--json", depends_on: "--json",
description: "Print JSON of all available formulae." description: "Print JSON of all available formulae."
switch :verbose, switch "-v", "--verbose",
description: "Show more verbose analytics data for <formula>." description: "Show more verbose analytics data for <formula>."
switch :debug
conflicts "--installed", "--all" conflicts "--installed", "--all"
end end
end end
def info def info
info_args.parse args = info_args.parse
if args.days.present? if args.days.present?
raise UsageError, "--days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days) raise UsageError, "--days must be one of #{VALID_DAYS.join(", ")}" unless VALID_DAYS.include?(args.days)
@ -83,17 +83,17 @@ module Homebrew
raise FormulaUnspecifiedError if args.no_named? raise FormulaUnspecifiedError if args.no_named?
end end
print_json print_json(args: args)
elsif args.github? elsif args.github?
raise FormulaUnspecifiedError if args.no_named? raise FormulaUnspecifiedError if args.no_named?
exec_browser(*args.formulae.map { |f| github_info(f) }) exec_browser(*args.formulae.map { |f| github_info(f) })
else else
print_info print_info(args: args)
end end
end end
def print_info def print_info(args:)
if args.no_named? if args.no_named?
if args.analytics? if args.analytics?
Utils::Analytics.output(args: args) Utils::Analytics.output(args: args)
@ -126,7 +126,7 @@ module Homebrew
end end
end end
def print_json def print_json(args:)
ff = if args.all? ff = if args.all?
Formula.sort Formula.sort
elsif args.installed? elsif args.installed?

View File

@ -24,7 +24,7 @@ module Homebrew
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
installed formulae or, every 30 days, for all formulae. installed formulae or, every 30 days, for all formulae.
EOS EOS
switch :debug, switch "-d", "--debug",
description: "If brewing fails, open an interactive debugging session with access to IRB "\ description: "If brewing fails, open an interactive debugging session with access to IRB "\
"or a shell inside the temporary build directory." "or a shell inside the temporary build directory."
flag "--env=", flag "--env=",
@ -74,7 +74,7 @@ module Homebrew
switch "-f", "--force", switch "-f", "--force",
description: "Install without checking for previously installed keg-only or "\ description: "Install without checking for previously installed keg-only or "\
"non-migrated versions." "non-migrated versions."
switch :verbose, switch "-v", "--verbose",
description: "Print the verification and postinstall steps." description: "Print the verification and postinstall steps."
switch "--display-times", switch "--display-times",
env: :display_install_times, env: :display_install_times,

View File

@ -14,7 +14,7 @@ module Homebrew
List installed formulae that are not dependencies of another installed formula. List installed formulae that are not dependencies of another installed formula.
EOS EOS
switch :debug
max_named 0 max_named 0
end end
end end

View File

@ -23,14 +23,13 @@ module Homebrew
"`brew link --overwrite` without actually linking or deleting any files." "`brew link --overwrite` without actually linking or deleting any files."
switch "-f", "--force", switch "-f", "--force",
description: "Allow keg-only formulae to be linked." description: "Allow keg-only formulae to be linked."
switch :verbose
switch :debug
min_named :keg min_named :keg
end end
end end
def link def link
link_args.parse args = link_args.parse
mode = OpenStruct.new mode = OpenStruct.new

View File

@ -45,16 +45,15 @@ module Homebrew
description: "Reverse the order of the sort to list the oldest entries first." description: "Reverse the order of the sort to list the oldest entries first."
switch "-t", switch "-t",
description: "Sort by time modified, listing most recently modified first." description: "Sort by time modified, listing most recently modified first."
switch :verbose
switch :debug
["--unbrewed", "--multiple", "--pinned", "-l", "-r", "-t"].each { |flag| conflicts "--cask", flag } ["--unbrewed", "--multiple", "--pinned", "-l", "-r", "-t"].each { |flag| conflicts "--cask", flag }
end end
end end
def list def list
list_args.parse args = list_args.parse
return list_casks if args.cask? return list_casks(args: args) if args.cask?
return list_unbrewed if args.unbrewed? return list_unbrewed if args.unbrewed?
@ -67,7 +66,7 @@ module Homebrew
end end
if args.pinned? || args.versions? if args.pinned? || args.versions?
filtered_list filtered_list args: args
elsif args.no_named? elsif args.no_named?
if args.full_name? if args.full_name?
full_names = Formula.installed.map(&:full_name).sort(&tap_and_name_comparison) full_names = Formula.installed.map(&:full_name).sort(&tap_and_name_comparison)
@ -76,7 +75,14 @@ module Homebrew
puts Formatter.columns(full_names) puts Formatter.columns(full_names)
else else
ENV["CLICOLOR"] = nil ENV["CLICOLOR"] = nil
safe_system "ls", *args.passthrough << HOMEBREW_CELLAR
ls_args = []
ls_args << "-1" if args.public_send(:'1?')
ls_args << "-l" if args.l?
ls_args << "-r" if args.r?
ls_args << "-t" if args.t?
safe_system "ls", *ls_args, HOMEBREW_CELLAR
end end
elsif args.verbose? || !$stdout.tty? elsif args.verbose? || !$stdout.tty?
system_command! "find", args: args.kegs.map(&:to_s) + %w[-not -type d -print], print_stdout: true system_command! "find", args: args.kegs.map(&:to_s) + %w[-not -type d -print], print_stdout: true
@ -128,7 +134,7 @@ module Homebrew
safe_system "find", *arguments safe_system "find", *arguments
end end
def filtered_list def filtered_list(args:)
names = if args.no_named? names = if args.no_named?
Formula.racks Formula.racks
else else
@ -157,7 +163,7 @@ module Homebrew
end end
end end
def list_casks def list_casks(args:)
cask_list = Cask::Cmd::List.new args.named cask_list = Cask::Cmd::List.new args.named
cask_list.one = ARGV.include? "-1" cask_list.one = ARGV.include? "-1"
cask_list.versions = args.versions? cask_list.versions = args.versions?

View File

@ -20,14 +20,17 @@ module Homebrew
description: "Also print diffstat from commit." description: "Also print diffstat from commit."
switch "--oneline", switch "--oneline",
description: "Print only one line per commit." description: "Print only one line per commit."
flag "-1", "--max-count", switch "-1",
description: "Print only one or a specified number of commits." description: "Print only one commit."
flag "-n", "--max-count=",
description: "Print only a specified number of commits."
max_named 1 max_named 1
conflicts "-1", "--max-count"
end end
end end
def log def log
log_args.parse args = log_args.parse
# As this command is simplifying user-run commands then let's just use a # As this command is simplifying user-run commands then let's just use a
# user path, too. # user path, too.
@ -38,11 +41,11 @@ module Homebrew
else else
path = Formulary.path(args.named.first) path = Formulary.path(args.named.first)
tap = Tap.from_path(path) tap = Tap.from_path(path)
git_log path.dirname, path, tap git_log path.dirname, path, tap, args: args
end end
end end
def git_log(cd_dir, path = nil, tap = nil) def git_log(cd_dir, path = nil, tap = nil, args:)
cd cd_dir cd cd_dir
repo = Utils.popen_read("git rev-parse --show-toplevel").chomp repo = Utils.popen_read("git rev-parse --show-toplevel").chomp
if tap if tap
@ -62,8 +65,14 @@ module Homebrew
git -C "#{git_cd}" fetch --unshallow git -C "#{git_cd}" fetch --unshallow
EOS EOS
end end
system_args = args.options_only
system_args += ["--follow", "--", path] if path.present? git_args = []
system "git", "log", *system_args git_args << "--patch" if args.patch?
git_args << "--stat" if args.stat?
git_args << "--oneline" if args.oneline?
git_args << "-1" if args.public_send(:'1?')
git_args << "--max-count" << args.max_count if args.max_count
git_args += ["--follow", "--", path] if path.present?
system "git", "log", *git_args
end end
end end

View File

@ -17,8 +17,7 @@ module Homebrew
switch "-f", "--force", switch "-f", "--force",
description: "Treat installed <formula> and provided <formula> as if they are from "\ description: "Treat installed <formula> and provided <formula> as if they are from "\
"the same taps and migrate them anyway." "the same taps and migrate them anyway."
switch :verbose
switch :debug
min_named :formula min_named :formula
end end
end end

View File

@ -20,13 +20,11 @@ module Homebrew
comma_array "--hide", comma_array "--hide",
description: "Act as if none of the specified <hidden> are installed. <hidden> should be "\ description: "Act as if none of the specified <hidden> are installed. <hidden> should be "\
"a comma-separated list of formulae." "a comma-separated list of formulae."
switch :verbose
switch :debug
end end
end end
def missing def missing
missing_args.parse args = missing_args.parse
return unless HOMEBREW_CELLAR.exist? return unless HOMEBREW_CELLAR.exist?

View File

@ -23,18 +23,18 @@ module Homebrew
description: "Show options for all available formulae." description: "Show options for all available formulae."
flag "--command=", flag "--command=",
description: "Show options for the specified <command>." description: "Show options for the specified <command>."
switch :debug
conflicts "--installed", "--all", "--command" conflicts "--installed", "--all", "--command"
end end
end end
def options def options
options_args.parse args = options_args.parse
if args.all? if args.all?
puts_options Formula.to_a.sort puts_options Formula.to_a.sort, args: args
elsif args.installed? elsif args.installed?
puts_options Formula.installed.sort puts_options Formula.installed.sort, args: args
elsif !args.command.nil? elsif !args.command.nil?
path = Commands.path(args.command) path = Commands.path(args.command)
odie "Unknown command: #{args.command}" unless path odie "Unknown command: #{args.command}" unless path
@ -54,7 +54,7 @@ module Homebrew
elsif args.no_named? elsif args.no_named?
raise FormulaUnspecifiedError raise FormulaUnspecifiedError
else else
puts_options args.formulae puts_options args.formulae, args: args
end end
end end
@ -72,7 +72,7 @@ module Homebrew
options options
end end
def puts_options(formulae) def puts_options(formulae, args:)
formulae.each do |f| formulae.each do |f|
next if f.options.empty? next if f.options.empty?

View File

@ -17,9 +17,9 @@ module Homebrew
List installed formulae that have an updated version available. By default, version List installed formulae that have an updated version available. By default, version
information is displayed in interactive shells, and suppressed otherwise. information is displayed in interactive shells, and suppressed otherwise.
EOS EOS
switch :quiet, switch "-q", "--quiet",
description: "List only the names of outdated kegs (takes precedence over `--verbose`)." description: "List only the names of outdated kegs (takes precedence over `--verbose`)."
switch :verbose, switch "-v", "--verbose",
description: "Include detailed version information." description: "Include detailed version information."
flag "--json", flag "--json",
description: "Print output in JSON format. There are two versions: v1 and v2. " \ description: "Print output in JSON format. There are two versions: v1 and v2. " \
@ -35,16 +35,16 @@ module Homebrew
description: "Treat all arguments as formulae." description: "Treat all arguments as formulae."
switch "--cask", switch "--cask",
description: "Treat all arguments as casks." description: "Treat all arguments as casks."
switch :debug
conflicts "--quiet", "--verbose", "--json" conflicts "--quiet", "--verbose", "--json"
conflicts "--formula", "--cask" conflicts "--formula", "--cask"
end end
end end
def outdated def outdated
outdated_args.parse args = outdated_args.parse
case json_version case json_version(args.json)
when :v1, :default when :v1, :default
# TODO: enable for next major/minor release # TODO: enable for next major/minor release
# odeprecated "brew outdated --json#{json_version == :v1 ? "=v1" : ""}", "brew outdated --json=v2" # odeprecated "brew outdated --json#{json_version == :v1 ? "=v1" : ""}", "brew outdated --json=v2"
@ -55,7 +55,7 @@ module Homebrew
outdated_casks outdated_casks
end end
puts JSON.generate(json_info(outdated)) puts JSON.generate(json_info(outdated, args: args))
when :v2 when :v2
formulae, casks = if args.formula? formulae, casks = if args.formula?
@ -67,8 +67,8 @@ module Homebrew
end end
json = { json = {
"formulae" => json_info(formulae), "formulae" => json_info(formulae, args: args),
"casks" => json_info(casks), "casks" => json_info(casks, args: args),
} }
puts JSON.generate(json) puts JSON.generate(json)
@ -83,13 +83,13 @@ module Homebrew
outdated_formulae_casks.flatten outdated_formulae_casks.flatten
end end
print_outdated(outdated) print_outdated(outdated, args: args)
end end
Homebrew.failed = args.named.present? && outdated.present? Homebrew.failed = args.named.present? && outdated.present?
end end
def print_outdated(formulae_or_casks) def print_outdated(formulae_or_casks, args:)
formulae_or_casks.each do |formula_or_cask| formulae_or_casks.each do |formula_or_cask|
if formula_or_cask.is_a?(Formula) if formula_or_cask.is_a?(Formula)
f = formula_or_cask f = formula_or_cask
@ -127,7 +127,7 @@ module Homebrew
end end
end end
def json_info(formulae_or_casks) def json_info(formulae_or_casks, args:)
formulae_or_casks.map do |formula_or_cask| formulae_or_casks.map do |formula_or_cask|
if formula_or_cask.is_a?(Formula) if formula_or_cask.is_a?(Formula)
f = formula_or_cask f = formula_or_cask
@ -156,7 +156,7 @@ module Homebrew
($stdout.tty? || args.verbose?) && !args.quiet? ($stdout.tty? || args.verbose?) && !args.quiet?
end end
def json_version def json_version(version)
version_hash = { version_hash = {
nil => nil, nil => nil,
true => :default, true => :default,
@ -164,9 +164,9 @@ module Homebrew
"v2" => :v2, "v2" => :v2,
} }
raise UsageError, "invalid JSON version: #{args.json}" unless version_hash.include? args.json raise UsageError, "invalid JSON version: #{version}" unless version_hash.include?(version)
version_hash[args.json] version_hash[version]
end end
def outdated_formulae def outdated_formulae

View File

@ -14,13 +14,13 @@ module Homebrew
Pin the specified <formula>, preventing them from being upgraded when Pin the specified <formula>, preventing them from being upgraded when
issuing the `brew upgrade` <formula> command. See also `unpin`. issuing the `brew upgrade` <formula> command. See also `unpin`.
EOS EOS
switch :debug
min_named :formula min_named :formula
end end
end end
def pin def pin
pin_args.parse args = pin_args.parse
args.resolved_formulae.each do |f| args.resolved_formulae.each do |f|
if f.pinned? if f.pinned?

View File

@ -14,8 +14,7 @@ module Homebrew
Rerun the post-install steps for <formula>. Rerun the post-install steps for <formula>.
EOS EOS
switch :verbose
switch :debug
min_named :keg min_named :keg
end end
end end

View File

@ -20,13 +20,11 @@ module Homebrew
description: "Verify any alias symlinks in each tap." description: "Verify any alias symlinks in each tap."
switch "--syntax", switch "--syntax",
description: "Syntax-check all of Homebrew's Ruby files (if no `<tap>` is passed)." description: "Syntax-check all of Homebrew's Ruby files (if no `<tap>` is passed)."
switch :verbose
switch :debug
end end
end end
def readall def readall
readall_args.parse args = readall_args.parse
if args.syntax? && args.no_named? if args.syntax? && args.no_named?
scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb" scan_files = "#{HOMEBREW_LIBRARY_PATH}/**/*.rb"

View File

@ -26,7 +26,7 @@ module Homebrew
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
reinstalled formulae or, every 30 days, for all formulae. reinstalled formulae or, every 30 days, for all formulae.
EOS EOS
switch :debug, switch "-d", "--debug",
description: "If brewing fails, open an interactive debugging session with access to IRB "\ description: "If brewing fails, open an interactive debugging session with access to IRB "\
"or a shell inside the temporary build directory." "or a shell inside the temporary build directory."
switch "-s", "--build-from-source", switch "-s", "--build-from-source",
@ -43,7 +43,7 @@ module Homebrew
switch "-f", "--force", switch "-f", "--force",
description: "Install without checking for previously installed keg-only or "\ description: "Install without checking for previously installed keg-only or "\
"non-migrated versions." "non-migrated versions."
switch :verbose, switch "-v", "--verbose",
description: "Print the verification and postinstall steps." description: "Print the verification and postinstall steps."
switch "--display-times", switch "--display-times",
env: :display_install_times, env: :display_install_times,

View File

@ -51,14 +51,13 @@ module Homebrew
switch s, switch s,
description: "Search for <text> in the given package manager's list." description: "Search for <text> in the given package manager's list."
end end
switch :verbose
switch :debug
conflicts(*package_manager_switches) conflicts(*package_manager_switches)
end end
end end
def search def search
search_args.parse args = search_args.parse
if package_manager = PACKAGE_MANAGERS.find { |name,| args[:"#{name}?"] } if package_manager = PACKAGE_MANAGERS.find { |name,| args[:"#{name}?"] }
_, url = package_manager _, url = package_manager

View File

@ -14,14 +14,13 @@ module Homebrew
Symlink all of the specified <version> of <formula>'s installation into Homebrew's prefix. Symlink all of the specified <version> of <formula>'s installation into Homebrew's prefix.
EOS EOS
switch :verbose
switch :debug
named 2 named 2
end end
end end
def switch def switch
switch_args.parse args = switch_args.parse
name = args.named.first name = args.named.first
rack = Formulary.to_rack(name) rack = Formulary.to_rack(name)

View File

@ -20,12 +20,11 @@ module Homebrew
description: "Print a JSON representation of <tap>. Currently the default and only accepted "\ description: "Print a JSON representation of <tap>. Currently the default and only accepted "\
"value for <version> is `v1`. See the docs for examples of using the JSON "\ "value for <version> is `v1`. See the docs for examples of using the JSON "\
"output: <https://docs.brew.sh/Querying-Brew>" "output: <https://docs.brew.sh/Querying-Brew>"
switch :debug
end end
end end
def tap_info def tap_info
tap_info_args.parse args = tap_info_args.parse
taps = if args.installed? taps = if args.installed?
Tap Tap

View File

@ -36,14 +36,13 @@ module Homebrew
description: "Migrate tapped formulae from symlink-based to directory-based structure." description: "Migrate tapped formulae from symlink-based to directory-based structure."
switch "--list-pinned", switch "--list-pinned",
description: "List all pinned taps." description: "List all pinned taps."
switch :quiet
switch :debug
max_named 2 max_named 2
end end
end end
def tap def tap
tap_args.parse args = tap_args.parse
if args.repair? if args.repair?
Tap.each(&:link_completions_and_manpages) Tap.each(&:link_completions_and_manpages)
@ -63,7 +62,7 @@ module Homebrew
tap = Tap.fetch(args.named.first) tap = Tap.fetch(args.named.first)
begin begin
tap.install clone_target: args.named.second, tap.install clone_target: args.named.second,
force_auto_update: force_auto_update?, force_auto_update: force_auto_update?(args: args),
quiet: args.quiet?, quiet: args.quiet?,
full_clone: full_clone full_clone: full_clone
rescue TapRemoteMismatchError => e rescue TapRemoteMismatchError => e
@ -74,7 +73,7 @@ module Homebrew
end end
end end
def force_auto_update? def force_auto_update?(args:)
# if no relevant flag is present, return nil, meaning "no change" # if no relevant flag is present, return nil, meaning "no change"
true if args.force_auto_update? true if args.force_auto_update?
end end

View File

@ -24,7 +24,7 @@ module Homebrew
switch "--ignore-dependencies", switch "--ignore-dependencies",
description: "Don't fail uninstall, even if <formula> is a dependency of any installed "\ description: "Don't fail uninstall, even if <formula> is a dependency of any installed "\
"formulae." "formulae."
switch :debug
min_named :formula min_named :formula
end end
end end

View File

@ -18,14 +18,13 @@ module Homebrew
switch "-n", "--dry-run", switch "-n", "--dry-run",
description: "List files which would be unlinked without actually unlinking or "\ description: "List files which would be unlinked without actually unlinking or "\
"deleting any files." "deleting any files."
switch :verbose
switch :debug
min_named :keg min_named :keg
end end
end end
def unlink def unlink
unlink_args.parse args = unlink_args.parse
mode = OpenStruct.new mode = OpenStruct.new
mode.dry_run = true if args.dry_run? mode.dry_run = true if args.dry_run?

View File

@ -14,14 +14,13 @@ module Homebrew
Unpin <formula>, allowing them to be upgraded by `brew upgrade` <formula>. Unpin <formula>, allowing them to be upgraded by `brew upgrade` <formula>.
See also `pin`. See also `pin`.
EOS EOS
switch :verbose
switch :debug
min_named :formula min_named :formula
end end
end end
def unpin def unpin
unpin_args.parse args = unpin_args.parse
args.resolved_formulae.each do |f| args.resolved_formulae.each do |f|
if f.pinned? if f.pinned?

View File

@ -12,13 +12,13 @@ module Homebrew
Remove a tapped formula repository. Remove a tapped formula repository.
EOS EOS
switch :debug
min_named 1 min_named 1
end end
end end
def untap def untap
untap_args.parse args = untap_args.parse
args.named.each do |tapname| args.named.each do |tapname|
tap = Tap.fetch(tapname) tap = Tap.fetch(tapname)

View File

@ -30,9 +30,7 @@ module Homebrew
switch "-f", "--force", switch "-f", "--force",
description: "Treat installed and updated formulae as if they are from "\ description: "Treat installed and updated formulae as if they are from "\
"the same taps and migrate them anyway." "the same taps and migrate them anyway."
switch :quiet
switch :verbose
switch :debug
hide_from_man_page! hide_from_man_page!
end end
end end

View File

@ -23,7 +23,7 @@ module Homebrew
Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the Unless `HOMEBREW_NO_INSTALL_CLEANUP` is set, `brew cleanup` will then be run for the
upgraded formulae or, every 30 days, for all formulae. upgraded formulae or, every 30 days, for all formulae.
EOS EOS
switch :debug, switch "-d", "--debug",
description: "If brewing fails, open an interactive debugging session with access to IRB "\ description: "If brewing fails, open an interactive debugging session with access to IRB "\
"or a shell inside the temporary build directory." "or a shell inside the temporary build directory."
switch "-s", "--build-from-source", switch "-s", "--build-from-source",
@ -46,7 +46,7 @@ module Homebrew
switch "-f", "--force", switch "-f", "--force",
description: "Install without checking for previously installed keg-only or "\ description: "Install without checking for previously installed keg-only or "\
"non-migrated versions." "non-migrated versions."
switch :verbose, switch "-v", "--verbose",
description: "Print the verification and postinstall steps." description: "Print the verification and postinstall steps."
switch "--display-times", switch "--display-times",
env: :display_install_times, env: :display_install_times,
@ -71,7 +71,7 @@ module Homebrew
named_casks_specified = !casks.empty? && formulae.empty? named_casks_specified = !casks.empty? && formulae.empty?
upgrade_outdated_formulae(formulae, args: args) unless named_casks_specified upgrade_outdated_formulae(formulae, args: args) unless named_casks_specified
upgrade_outdated_casks(casks) unless named_formulae_specified upgrade_outdated_casks(casks, args: args) unless named_formulae_specified
end end
def upgrade_outdated_formulae(formulae, args:) def upgrade_outdated_formulae(formulae, args:)
@ -132,7 +132,7 @@ module Homebrew
Homebrew.messages.display_messages(display_times: args.display_times?) Homebrew.messages.display_messages(display_times: args.display_times?)
end end
def upgrade_outdated_casks(casks) def upgrade_outdated_casks(casks, args:)
cask_upgrade = Cask::Cmd::Upgrade.new(casks) cask_upgrade = Cask::Cmd::Upgrade.new(casks)
cask_upgrade.force = args.force? cask_upgrade.force = args.force?
cask_upgrade.dry_run = args.dry_run? cask_upgrade.dry_run = args.dry_run?

View File

@ -40,14 +40,14 @@ module Homebrew
description: "Show usage of <formula> by development builds." description: "Show usage of <formula> by development builds."
switch "--HEAD", switch "--HEAD",
description: "Show usage of <formula> by HEAD builds." description: "Show usage of <formula> by HEAD builds."
switch :debug
conflicts "--devel", "--HEAD" conflicts "--devel", "--HEAD"
min_named :formula min_named :formula
end end
end end
def uses def uses
uses_args.parse args = uses_args.parse
odeprecated "brew uses --devel" if args.devel? odeprecated "brew uses --devel" if args.devel?
odeprecated "brew uses --HEAD" if args.HEAD? odeprecated "brew uses --HEAD" if args.HEAD?
@ -70,11 +70,14 @@ module Homebrew
!args.include_optional? && !args.include_optional? &&
!args.skip_recommended? !args.skip_recommended?
recursive = args.recursive?
includes, ignores = args_includes_ignores(args)
uses = if use_runtime_dependents && !used_formulae_missing uses = if use_runtime_dependents && !used_formulae_missing
used_formulae.map(&:runtime_installed_formula_dependents) used_formulae.map(&:runtime_installed_formula_dependents)
.reduce(&:&) .reduce(&:&)
.select(&:any_version_installed?) + .select(&:any_version_installed?) +
select_used_dependents(dependents(Cask::Caskroom.casks), used_formulae) select_used_dependents(dependents(Cask::Caskroom.casks), used_formulae, recursive, includes, ignores)
else else
deps = if args.installed? deps = if args.installed?
dependents(Formula.installed + Cask::Caskroom.casks) dependents(Formula.installed + Cask::Caskroom.casks)
@ -82,7 +85,7 @@ module Homebrew
dependents(Formula.to_a + Cask::Cask.to_a) dependents(Formula.to_a + Cask::Cask.to_a)
end end
select_used_dependents(deps, used_formulae) select_used_dependents(deps, used_formulae, recursive, includes, ignores)
end end
return if uses.empty? return if uses.empty?
@ -91,10 +94,7 @@ module Homebrew
odie "Missing formulae should not have dependents!" if used_formulae_missing odie "Missing formulae should not have dependents!" if used_formulae_missing
end end
def select_used_dependents(dependents, used_formulae) def select_used_dependents(dependents, used_formulae, recursive, includes, ignores)
recursive = args.recursive?
includes, ignores = argv_includes_ignores(ARGV)
dependents.select do |d| dependents.select do |d|
deps = if recursive deps = if recursive
recursive_includes(Dependency, d, includes, ignores) recursive_includes(Dependency, d, includes, ignores)

View File

@ -3,23 +3,23 @@
require "cask_dependent" require "cask_dependent"
module DependenciesHelpers module DependenciesHelpers
def argv_includes_ignores(argv) def args_includes_ignores(args)
includes = [] includes = []
ignores = [] ignores = []
if argv.include? "--include-build" if args.include_build?
includes << "build?" includes << "build?"
else else
ignores << "build?" ignores << "build?"
end end
if argv.include? "--include-test" if args.include_test?
includes << "test?" includes << "test?"
else else
ignores << "test?" ignores << "test?"
end end
if argv.include? "--include-optional" if args.include_optional?
includes << "optional?" includes << "optional?"
else else
ignores << "optional?" ignores << "optional?"
@ -46,7 +46,7 @@ module DependenciesHelpers
klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep) klass.prune if !includes.include?("optional?") && !dependent.build.with?(dep)
elsif dep.build? || dep.test? elsif dep.build? || dep.test?
keep = false keep = false
keep ||= dep.test? && includes.include?("test?") && dependent == formula keep ||= dep.test? && includes.include?("test?") && dependent == root_dependent
keep ||= dep.build? && includes.include?("build?") keep ||= dep.build? && includes.include?("build?")
klass.prune unless keep klass.prune unless keep
end end

View File

@ -61,8 +61,7 @@ module Homebrew
comma_array "--except-cops", comma_array "--except-cops",
description: "Specify a comma-separated <cops> list to skip checking for violations of the listed "\ description: "Specify a comma-separated <cops> list to skip checking for violations of the listed "\
"RuboCop cops." "RuboCop cops."
switch :verbose
switch :debug
conflicts "--only", "--except" conflicts "--only", "--except"
conflicts "--only-cops", "--except-cops", "--strict" conflicts "--only-cops", "--except-cops", "--strict"
conflicts "--only-cops", "--except-cops", "--only" conflicts "--only-cops", "--except-cops", "--only"
@ -269,6 +268,12 @@ module Homebrew
valid_alias_names.map! { |a| "#{formula.tap}/#{a}" } valid_alias_names.map! { |a| "#{formula.tap}/#{a}" }
end end
# Fix naming based on what people expect.
if alias_name_major_minor == "adoptopenjdk@1.8"
valid_alias_names << "adoptopenjdk@8"
valid_alias_names.delete "adoptopenjdk@1"
end
valid_versioned_aliases = versioned_aliases & valid_alias_names valid_versioned_aliases = versioned_aliases & valid_alias_names
invalid_versioned_aliases = versioned_aliases - valid_alias_names invalid_versioned_aliases = versioned_aliases - valid_alias_names
@ -284,7 +289,7 @@ module Homebrew
end end
end end
unless invalid_versioned_aliases.empty? if invalid_versioned_aliases.present?
problem <<~EOS problem <<~EOS
Formula has invalid versioned aliases: Formula has invalid versioned aliases:
#{invalid_versioned_aliases.join("\n ")} #{invalid_versioned_aliases.join("\n ")}
@ -385,7 +390,7 @@ module Homebrew
end end
if self.class.aliases.include?(dep.name) && if self.class.aliases.include?(dep.name) &&
(dep_f.core_formula? || !dep_f.versioned_formula?) dep_f.core_formula? && !dep_f.versioned_formula?
problem "Dependency '#{dep.name}' from homebrew/core is an alias; " \ problem "Dependency '#{dep.name}' from homebrew/core is an alias; " \
"use the canonical name '#{dep.to_formula.full_name}'." "use the canonical name '#{dep.to_formula.full_name}'."
end end
@ -467,6 +472,7 @@ module Homebrew
end end
end end
# openssl@1.1 only needed for Linux
VERSIONED_KEG_ONLY_ALLOWLIST = %w[ VERSIONED_KEG_ONLY_ALLOWLIST = %w[
autoconf@2.13 autoconf@2.13
bash-completion@2 bash-completion@2
@ -474,6 +480,7 @@ module Homebrew
libsigc++@2 libsigc++@2
lua@5.1 lua@5.1
numpy@1.16 numpy@1.16
openssl@1.1
python@3.8 python@3.8
].freeze ].freeze
@ -489,7 +496,9 @@ module Homebrew
end end
end end
return if VERSIONED_KEG_ONLY_ALLOWLIST.include?(formula.name) || formula.name.start_with?("gcc@") return if VERSIONED_KEG_ONLY_ALLOWLIST.include?(formula.name)
return if formula.name.start_with?("adoptopenjdk@")
return if formula.name.start_with?("gcc@")
problem "Versioned formulae in homebrew/core should use `keg_only :versioned_formula`" problem "Versioned formulae in homebrew/core should use `keg_only :versioned_formula`"
end end

View File

@ -76,21 +76,20 @@ module Homebrew
"to the formula file." "to the formula file."
flag "--root-url=", flag "--root-url=",
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default." description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
switch :verbose
switch :debug
conflicts "--no-rebuild", "--keep-old" conflicts "--no-rebuild", "--keep-old"
min_named 1 min_named 1
end end
end end
def bottle def bottle
bottle_args.parse args = bottle_args.parse
return merge if args.merge? return merge(args: args) if args.merge?
ensure_relocation_formulae_installed! unless args.skip_relocation? ensure_relocation_formulae_installed! unless args.skip_relocation?
args.resolved_formulae.each do |f| args.resolved_formulae.each do |f|
bottle_formula f bottle_formula f, args: args
end end
end end
@ -103,7 +102,7 @@ module Homebrew
end end
end end
def keg_contain?(string, keg, ignores, formula_and_runtime_deps_names = nil) def keg_contain?(string, keg, ignores, formula_and_runtime_deps_names = nil, args:)
@put_string_exists_header, @put_filenames = nil @put_string_exists_header, @put_filenames = nil
print_filename = lambda do |str, filename| print_filename = lambda do |str, filename|
@ -211,7 +210,7 @@ module Homebrew
system "/usr/bin/sudo", "--non-interactive", "/usr/sbin/purge" system "/usr/bin/sudo", "--non-interactive", "/usr/sbin/purge"
end end
def bottle_formula(f) def bottle_formula(f, args:)
return ofail "Formula not installed or up-to-date: #{f.full_name}" unless f.latest_version_installed? return ofail "Formula not installed or up-to-date: #{f.full_name}" unless f.latest_version_installed?
unless tap = f.tap unless tap = f.tap
@ -328,14 +327,14 @@ module Homebrew
if args.skip_relocation? if args.skip_relocation?
skip_relocation = true skip_relocation = true
else else
relocatable = false if keg_contain?(prefix_check, keg, ignores, formula_and_runtime_deps_names) relocatable = false if keg_contain?(prefix_check, keg, ignores, formula_and_runtime_deps_names, args: args)
relocatable = false if keg_contain?(repository, keg, ignores) relocatable = false if keg_contain?(repository, keg, ignores, args: args)
relocatable = false if keg_contain?(cellar, keg, ignores, formula_and_runtime_deps_names) relocatable = false if keg_contain?(cellar, keg, ignores, formula_and_runtime_deps_names, args: args)
if prefix != prefix_check if prefix != prefix_check
relocatable = false if keg_contain_absolute_symlink_starting_with?(prefix, keg) relocatable = false if keg_contain_absolute_symlink_starting_with?(prefix, keg)
relocatable = false if keg_contain?("#{prefix}/etc", keg, ignores) relocatable = false if keg_contain?("#{prefix}/etc", keg, ignores, args: args)
relocatable = false if keg_contain?("#{prefix}/var", keg, ignores) relocatable = false if keg_contain?("#{prefix}/var", keg, ignores, args: args)
relocatable = false if keg_contain?("#{prefix}/share/vim", keg, ignores) relocatable = false if keg_contain?("#{prefix}/share/vim", keg, ignores, args: args)
end end
skip_relocation = relocatable && !keg.require_relocation? skip_relocation = relocatable && !keg.require_relocation?
end end
@ -434,7 +433,7 @@ module Homebrew
end end
end end
def merge def merge(args:)
bottles_hash = args.named.reduce({}) do |hash, json_file| bottles_hash = args.named.reduce({}) do |hash, json_file|
hash.deep_merge(JSON.parse(IO.read(json_file))) do |key, first, second| hash.deep_merge(JSON.parse(IO.read(json_file))) do |key, first, second|
if key == "cellar" if key == "cellar"

View File

@ -65,16 +65,14 @@ module Homebrew
description: "Specify the new git commit <revision> corresponding to the specified <tag>." description: "Specify the new git commit <revision> corresponding to the specified <tag>."
switch "-f", "--force", switch "-f", "--force",
description: "Ignore duplicate open PRs. Remove all mirrors if --mirror= was not specified." description: "Ignore duplicate open PRs. Remove all mirrors if --mirror= was not specified."
switch :quiet
switch :verbose
switch :debug
conflicts "--no-audit", "--strict" conflicts "--no-audit", "--strict"
conflicts "--url", "--tag" conflicts "--url", "--tag"
max_named 1 max_named 1
end end
end end
def use_correct_linux_tap(formula) def use_correct_linux_tap(formula, args:)
if OS.linux? && formula.tap.core_tap? if OS.linux? && formula.tap.core_tap?
tap_full_name = formula.tap.full_name.gsub("linuxbrew", "homebrew") tap_full_name = formula.tap.full_name.gsub("linuxbrew", "homebrew")
homebrew_core_url = "https://github.com/#{tap_full_name}" homebrew_core_url = "https://github.com/#{tap_full_name}"
@ -111,7 +109,7 @@ module Homebrew
end end
def bump_formula_pr def bump_formula_pr
bump_formula_pr_args.parse args = bump_formula_pr_args.parse
# As this command is simplifying user-run commands then let's just use a # As this command is simplifying user-run commands then let's just use a
# user path, too. # user path, too.
@ -126,11 +124,11 @@ module Homebrew
formula ||= determine_formula_from_url(new_url) if new_url formula ||= determine_formula_from_url(new_url) if new_url
raise FormulaUnspecifiedError unless formula raise FormulaUnspecifiedError unless formula
tap_full_name, origin_branch, previous_branch = use_correct_linux_tap(formula) tap_full_name, origin_branch, previous_branch = use_correct_linux_tap(formula, args: args)
check_open_pull_requests(formula, tap_full_name) check_open_pull_requests(formula, tap_full_name, args: args)
new_version = args.version new_version = args.version
check_all_pull_requests(formula, tap_full_name, version: new_version) if new_version check_all_pull_requests(formula, tap_full_name, version: new_version, args: args) if new_version
requested_spec = :stable requested_spec = :stable
formula_spec = formula.stable formula_spec = formula.stable
@ -161,10 +159,10 @@ module Homebrew
old_version = old_formula_version.to_s old_version = old_formula_version.to_s
forced_version = new_version.present? forced_version = new_version.present?
new_url_hash = if new_url && new_hash new_url_hash = if new_url && new_hash
check_all_pull_requests(formula, tap_full_name, url: new_url) unless new_version check_all_pull_requests(formula, tap_full_name, url: new_url, args: args) unless new_version
true true
elsif new_tag && new_revision elsif new_tag && new_revision
check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag) unless new_version check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version
false false
elsif !hash_type elsif !hash_type
odie "#{formula}: no --tag= or --version= argument specified!" if !new_tag && !new_version odie "#{formula}: no --tag= or --version= argument specified!" if !new_tag && !new_version
@ -175,7 +173,7 @@ module Homebrew
and old tag are both #{new_tag}. and old tag are both #{new_tag}.
EOS EOS
end end
check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag) unless new_version check_all_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) unless new_version
resource_path, forced_version = fetch_resource(formula, new_version, old_url, tag: new_tag) resource_path, forced_version = fetch_resource(formula, new_version, old_url, tag: new_tag)
new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD") new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD")
new_revision = new_revision.strip new_revision = new_revision.strip
@ -183,6 +181,7 @@ module Homebrew
elsif !new_url && !new_version elsif !new_url && !new_version
odie "#{formula}: no --url= or --version= argument specified!" odie "#{formula}: no --url= or --version= argument specified!"
else else
new_url ||= PyPI.update_pypi_url(old_url, new_version)
new_url ||= old_url.gsub(old_version, new_version) new_url ||= old_url.gsub(old_version, new_version)
if new_url == old_url if new_url == old_url
odie <<~EOS odie <<~EOS
@ -191,7 +190,7 @@ module Homebrew
#{new_url} #{new_url}
EOS EOS
end end
check_all_pull_requests(formula, tap_full_name, url: new_url) unless new_version check_all_pull_requests(formula, tap_full_name, url: new_url, args: args) unless new_version
resource_path, forced_version = fetch_resource(formula, new_version, new_url) resource_path, forced_version = fetch_resource(formula, new_version, new_url)
tar_file_extensions = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ] tar_file_extensions = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ]
if tar_file_extensions.any? { |extension| new_url.include? extension } if tar_file_extensions.any? { |extension| new_url.include? extension }
@ -295,7 +294,7 @@ module Homebrew
"", "",
] ]
end end
new_contents = inreplace_pairs(formula.path, replacement_pairs.uniq.compact) new_contents = inreplace_pairs(formula.path, replacement_pairs.uniq.compact, args: args)
new_formula_version = formula_version(formula, requested_spec, new_contents) new_formula_version = formula_version(formula, requested_spec, new_contents)
@ -335,10 +334,10 @@ module Homebrew
PyPI.update_python_resources! formula, new_formula_version, silent: true, ignore_non_pypi_packages: true PyPI.update_python_resources! formula, new_formula_version, silent: true, ignore_non_pypi_packages: true
end end
run_audit(formula, alias_rename, old_contents) run_audit(formula, alias_rename, old_contents, args: args)
formula.path.parent.cd do formula.path.parent.cd do
branch = "#{formula.name}-#{new_formula_version}" branch = "bump-#{formula.name}-#{new_formula_version}"
git_dir = Utils.popen_read("git rev-parse --git-dir").chomp git_dir = Utils.popen_read("git rev-parse --git-dir").chomp
shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow") shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow")
changed_files = [formula.path] changed_files = [formula.path]
@ -450,7 +449,7 @@ module Homebrew
[remote_url, username] [remote_url, username]
end end
def inreplace_pairs(path, replacement_pairs) def inreplace_pairs(path, replacement_pairs, args:)
if args.dry_run? if args.dry_run?
str = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read } str = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read }
contents = StringInreplaceExtension.new(str) contents = StringInreplaceExtension.new(str)
@ -497,13 +496,13 @@ module Homebrew
[] []
end end
def check_open_pull_requests(formula, tap_full_name) def check_open_pull_requests(formula, tap_full_name, args:)
# check for open requests # check for open requests
pull_requests = fetch_pull_requests(formula.name, tap_full_name, state: "open") pull_requests = fetch_pull_requests(formula.name, tap_full_name, state: "open")
check_for_duplicate_pull_requests(pull_requests) check_for_duplicate_pull_requests(pull_requests, args: args)
end end
def check_all_pull_requests(formula, tap_full_name, version: nil, url: nil, tag: nil) def check_all_pull_requests(formula, tap_full_name, version: nil, url: nil, tag: nil, args:)
unless version unless version
specs = {} specs = {}
specs[:tag] = tag if tag specs[:tag] = tag if tag
@ -511,10 +510,10 @@ module Homebrew
end end
# if we haven't already found open requests, try for an exact match across all requests # if we haven't already found open requests, try for an exact match across all requests
pull_requests = fetch_pull_requests("#{formula.name} #{version}", tap_full_name) if pull_requests.blank? pull_requests = fetch_pull_requests("#{formula.name} #{version}", tap_full_name) if pull_requests.blank?
check_for_duplicate_pull_requests(pull_requests) check_for_duplicate_pull_requests(pull_requests, args: args)
end end
def check_for_duplicate_pull_requests(pull_requests) def check_for_duplicate_pull_requests(pull_requests, args:)
return if pull_requests.blank? return if pull_requests.blank?
duplicates_message = <<~EOS duplicates_message = <<~EOS
@ -546,7 +545,7 @@ module Homebrew
[versioned_alias, "#{name}@#{new_alias_version}"] [versioned_alias, "#{name}@#{new_alias_version}"]
end end
def run_audit(formula, alias_rename, old_contents) def run_audit(formula, alias_rename, old_contents, args:)
if args.dry_run? if args.dry_run?
if args.no_audit? if args.no_audit?
ohai "Skipping `brew audit`" ohai "Skipping `brew audit`"

View File

@ -18,9 +18,7 @@ module Homebrew
description: "Print what would be done rather than doing it." description: "Print what would be done rather than doing it."
flag "--message=", flag "--message=",
description: "Append <message> to the default commit message." description: "Append <message> to the default commit message."
switch :quiet
switch :verbose
switch :debug
named :formula named :formula
end end
end end
@ -42,9 +40,14 @@ module Homebrew
end end
old = if formula.license old = if formula.license
license_string = if formula.license.length > 1
formula.license
else
"\"#{formula.license.first}\""
end
# insert replacement revision after license # insert replacement revision after license
<<~EOS <<~EOS
license "#{formula.license}" license #{license_string}
EOS EOS
elsif formula.path.read.include?("stable do\n") elsif formula.path.read.include?("stable do\n")
# insert replacement revision after homepage # insert replacement revision after homepage
@ -59,7 +62,7 @@ module Homebrew
else else
# insert replacement revision after :revision # insert replacement revision after :revision
<<~EOS <<~EOS
:revision => "#{formula_spec.specs[:revision]}" revision: "#{formula_spec.specs[:revision]}"
EOS EOS
end end
replacement = old + " revision 1\n" replacement = old + " revision 1\n"

View File

@ -17,7 +17,7 @@ module Homebrew
end end
def cat def cat
cat_args.parse args = cat_args.parse
cd HOMEBREW_REPOSITORY cd HOMEBREW_REPOSITORY
pager = if Homebrew::EnvConfig.bat? pager = if Homebrew::EnvConfig.bat?
@ -26,6 +26,6 @@ module Homebrew
else else
"cat" "cat"
end end
safe_system pager, args.formulae_paths.first, *args.passthrough safe_system pager, args.formulae_paths.first
end end
end end

View File

@ -13,14 +13,13 @@ module Homebrew
Display the path to the file being used when invoking `brew` <cmd>. Display the path to the file being used when invoking `brew` <cmd>.
EOS EOS
switch :verbose
switch :debug
min_named 1 min_named 1
end end
end end
def command def command
command_args.parse args = command_args.parse
args.named.each do |cmd| args.named.each do |cmd|
path = Commands.path(cmd) path = Commands.path(cmd)

View File

@ -56,8 +56,7 @@ module Homebrew
description: "Generate the new formula within the given tap, specified as <user>`/`<repo>." description: "Generate the new formula within the given tap, specified as <user>`/`<repo>."
switch "-f", "--force", switch "-f", "--force",
description: "Ignore errors for disallowed formula names and named that shadow aliases." description: "Ignore errors for disallowed formula names and named that shadow aliases."
switch :verbose
switch :debug
conflicts "--autotools", "--cmake", "--crystal", "--go", "--meson", "--node", "--perl", "--python", "--rust" conflicts "--autotools", "--cmake", "--crystal", "--go", "--meson", "--node", "--perl", "--python", "--rust"
named 1 named 1
end end

View File

@ -19,14 +19,13 @@ module Homebrew
description: "Explicitly set the <name> of the package being installed." description: "Explicitly set the <name> of the package being installed."
flag "--version=", flag "--version=",
description: "Explicitly set the <version> of the package being installed." description: "Explicitly set the <version> of the package being installed."
switch :verbose
switch :debug
max_named 0 max_named 0
end end
end end
def diy def diy
diy_args.parse args = diy_args.parse
path = Pathname.getwd path = Pathname.getwd

View File

@ -14,13 +14,11 @@ module Homebrew
Open <formula> in the editor set by `EDITOR` or `HOMEBREW_EDITOR`, or open the Open <formula> in the editor set by `EDITOR` or `HOMEBREW_EDITOR`, or open the
Homebrew repository for editing if no formula is provided. Homebrew repository for editing if no formula is provided.
EOS EOS
switch :verbose
switch :debug
end end
end end
def edit def edit
edit_args.parse args = edit_args.parse
unless (HOMEBREW_REPOSITORY/".git").directory? unless (HOMEBREW_REPOSITORY/".git").directory?
raise <<~EOS raise <<~EOS

View File

@ -91,13 +91,13 @@ module Homebrew
description: "Extract the specified <version> of <formula> instead of the most recent." description: "Extract the specified <version> of <formula> instead of the most recent."
switch "-f", "--force", switch "-f", "--force",
description: "Overwrite the destination formula if it already exists." description: "Overwrite the destination formula if it already exists."
switch :debug
named 2 named 2
end end
end end
def extract def extract
extract_args.parse args = extract_args.parse
if args.named.first !~ HOMEBREW_TAP_FORMULA_REGEX if args.named.first !~ HOMEBREW_TAP_FORMULA_REGEX
name = args.named.first.downcase name = args.named.first.downcase

View File

@ -13,14 +13,13 @@ module Homebrew
Display the path where <formula> is located. Display the path where <formula> is located.
EOS EOS
switch :verbose
switch :debug
min_named :formula min_named :formula
end end
end end
def formula def formula
formula_args.parse args = formula_args.parse
args.formulae_paths.each(&method(:puts)) args.formulae_paths.each(&method(:puts))
end end

View File

@ -13,7 +13,7 @@ module Homebrew
Install Homebrew's Bundler gems. Install Homebrew's Bundler gems.
EOS EOS
switch :debug
max_named 0 max_named 0
end end
end end

View File

@ -19,7 +19,7 @@ module Homebrew
def irb_args def irb_args
# work around IRB modifying ARGV. # work around IRB modifying ARGV.
Homebrew::CLI::Parser.new(ARGV.dup.freeze) do Homebrew::CLI::Parser.new do
usage_banner <<~EOS usage_banner <<~EOS
`irb` [<options>] `irb` [<options>]
@ -34,7 +34,7 @@ module Homebrew
end end
def irb def irb
irb_args.parse args = irb_args.parse(ARGV.dup.freeze)
if args.examples? if args.examples?
puts "'v8'.f # => instance of the v8 formula" puts "'v8'.f # => instance of the v8 formula"

View File

@ -24,13 +24,11 @@ module Homebrew
switch "--cached", switch "--cached",
description: "Print the cached linkage values stored in `HOMEBREW_CACHE`, set by a previous "\ description: "Print the cached linkage values stored in `HOMEBREW_CACHE`, set by a previous "\
"`brew linkage` run." "`brew linkage` run."
switch :verbose
switch :debug
end end
end end
def linkage def linkage
linkage_args.parse args = linkage_args.parse
CacheStoreDatabase.use(:linkage) do |db| CacheStoreDatabase.use(:linkage) do |db|
kegs = if args.kegs.empty? kegs = if args.kegs.empty?

View File

@ -36,7 +36,7 @@ module Homebrew
odie "`brew man --link` is now done automatically by `brew update`." if args.link? odie "`brew man --link` is now done automatically by `brew update`." if args.link?
Commands.rebuild_internal_commands_completion_list Commands.rebuild_internal_commands_completion_list
regenerate_man_pages(args: args) regenerate_man_pages(preserve_date: args.fail_if_changed?)
if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/Manpage.md", "manpages", "completions" if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/Manpage.md", "manpages", "completions"
puts "No changes to manpage or completions output detected." puts "No changes to manpage or completions output detected."
@ -45,15 +45,15 @@ module Homebrew
end end
end end
def regenerate_man_pages(args:) def regenerate_man_pages(preserve_date:)
Homebrew.install_bundler_gems! Homebrew.install_bundler_gems!
markup = build_man_page markup = build_man_page
convert_man_page(markup, TARGET_DOC_PATH/"Manpage.md", args: args) convert_man_page(markup, TARGET_DOC_PATH/"Manpage.md", preserve_date: preserve_date)
convert_man_page(markup, TARGET_MAN_PATH/"brew.1", args: args) convert_man_page(markup, TARGET_MAN_PATH/"brew.1", preserve_date: preserve_date)
cask_markup = (SOURCE_PATH/"brew-cask.1.md").read cask_markup = (SOURCE_PATH/"brew-cask.1.md").read
convert_man_page(cask_markup, TARGET_MAN_PATH/"brew-cask.1", args: args) convert_man_page(cask_markup, TARGET_MAN_PATH/"brew-cask.1", preserve_date: preserve_date)
end end
def build_man_page def build_man_page
@ -94,14 +94,13 @@ module Homebrew
path.basename.to_s.sub(/\.(rb|sh)$/, "").sub(/^--/, "~~") path.basename.to_s.sub(/\.(rb|sh)$/, "").sub(/^--/, "~~")
end end
def convert_man_page(markup, target, args:) def convert_man_page(markup, target, preserve_date:)
manual = target.basename(".1") manual = target.basename(".1")
organisation = "Homebrew" organisation = "Homebrew"
# Set the manpage date to the existing one if we're checking for changes. # Set the manpage date to the existing one if we're checking for changes.
# This avoids the only change being e.g. a new date. # This avoids the only change being e.g. a new date.
date = if args.fail_if_changed? && date = if preserve_date && target.extname == ".1" && target.exist?
target.extname == ".1" && target.exist?
/"(\d{1,2})" "([A-Z][a-z]+) (\d{4})" "#{organisation}" "#{manual}"/ =~ target.read /"(\d{1,2})" "([A-Z][a-z]+) (\d{4})" "#{organisation}" "#{manual}"/ =~ target.read
Date.parse("#{Regexp.last_match(1)} #{Regexp.last_match(2)} #{Regexp.last_match(3)}") Date.parse("#{Regexp.last_match(1)} #{Regexp.last_match(2)} #{Regexp.last_match(3)}")
else else
@ -169,7 +168,7 @@ module Homebrew
def cmd_parser_manpage_lines(cmd_parser) def cmd_parser_manpage_lines(cmd_parser)
lines = [format_usage_banner(cmd_parser.usage_banner_text)] lines = [format_usage_banner(cmd_parser.usage_banner_text)]
lines += cmd_parser.processed_options.map do |short, long, _, desc| lines += cmd_parser.processed_options.map do |short, long, _, desc|
next if !long.nil? && cmd_parser.global_option?(cmd_parser.option_to_name(long), desc) next if !long.nil? && Homebrew::CLI::Parser.global_options.include?([short, long, desc])
generate_option_doc(short, long, desc) generate_option_doc(short, long, desc)
end.reject(&:blank?) end.reject(&:blank?)
@ -191,7 +190,7 @@ module Homebrew
end end
# Omit the common global_options documented separately in the man page. # Omit the common global_options documented separately in the man page.
next if line.match?(/--(debug|force|help|quiet|verbose) /) next if line.match?(/--(debug|help|quiet|verbose) /)
# Format one option or a comma-separated pair of short and long options. # Format one option or a comma-separated pair of short and long options.
lines << line.gsub(/^ +(-+[a-z-]+), (-+[a-z-]+) +/, "* `\\1`, `\\2`:\n ") lines << line.gsub(/^ +(-+[a-z-]+), (-+[a-z-]+) +/, "* `\\1`, `\\2`:\n ")
@ -203,8 +202,7 @@ module Homebrew
def global_options_manpage def global_options_manpage
lines = ["These options are applicable across multiple subcommands.\n"] lines = ["These options are applicable across multiple subcommands.\n"]
lines += Homebrew::CLI::Parser.global_options.values.map do |names, _, desc| lines += Homebrew::CLI::Parser.global_options.map do |short, long, desc|
short, long = names
generate_option_doc(short, long, desc) generate_option_doc(short, long, desc)
end end
lines.join("\n") lines.join("\n")

View File

@ -19,8 +19,7 @@ module Homebrew
description: "Upload to the specified Bintray repository (default: `mirror`)." description: "Upload to the specified Bintray repository (default: `mirror`)."
switch "--no-publish", switch "--no-publish",
description: "Upload to Bintray, but don't publish." description: "Upload to Bintray, but don't publish."
switch :verbose
switch :debug
hide_from_man_page! hide_from_man_page!
min_named :formula min_named :formula
end end

View File

@ -25,8 +25,7 @@ module Homebrew
description: "Run `brew pr-publish` on matching pull requests." description: "Run `brew pr-publish` on matching pull requests."
switch "--ignore-failures", switch "--ignore-failures",
description: "Include pull requests that have failing status checks." description: "Include pull requests that have failing status checks."
switch :verbose
switch :debug
max_named 0 max_named 0
end end
end end

View File

@ -18,13 +18,13 @@ module Homebrew
description: "Target tap repository (default: `homebrew/core`)." description: "Target tap repository (default: `homebrew/core`)."
flag "--workflow=", flag "--workflow=",
description: "Target workflow filename (default: `publish-commit-bottles.yml`)." description: "Target workflow filename (default: `publish-commit-bottles.yml`)."
switch :verbose
min_named 1 min_named 1
end end
end end
def pr_publish def pr_publish
pr_publish_args.parse args = pr_publish_args.parse
tap = Tap.fetch(Homebrew.args.tap || CoreTap.instance.name) tap = Tap.fetch(Homebrew.args.tap || CoreTap.instance.name)
workflow = Homebrew.args.workflow || "publish-commit-bottles.yml" workflow = Homebrew.args.workflow || "publish-commit-bottles.yml"

View File

@ -49,8 +49,7 @@ module Homebrew
flag "--bintray-mirror=", flag "--bintray-mirror=",
description: "Use the specified Bintray repository to automatically mirror stable URLs "\ description: "Use the specified Bintray repository to automatically mirror stable URLs "\
"defined in the formulae (default: `mirror`)." "defined in the formulae (default: `mirror`)."
switch :verbose
switch :debug
min_named 1 min_named 1
end end
end end
@ -130,7 +129,7 @@ module Homebrew
end end
end end
def check_branch(path, ref) def check_branch(path, ref, args:)
branch = Utils.popen_read("git", "-C", path, "symbolic-ref", "--short", "HEAD").strip branch = Utils.popen_read("git", "-C", path, "symbolic-ref", "--short", "HEAD").strip
return if branch == ref || args.clean? || args.branch_okay? return if branch == ref || args.clean? || args.branch_okay?
@ -155,8 +154,8 @@ module Homebrew
else else
odebug "Mirroring #{mirror_url}" odebug "Mirroring #{mirror_url}"
mirror_args = ["mirror", f.full_name] mirror_args = ["mirror", f.full_name]
mirror_args << "--debug" if Homebrew.args.debug? mirror_args << "--debug" if args.debug?
mirror_args << "--verbose" if Homebrew.args.verbose? mirror_args << "--verbose" if args.verbose?
mirror_args << "--bintray-org=#{org}" if org mirror_args << "--bintray-org=#{org}" if org
mirror_args << "--bintray-repo=#{repo}" if repo mirror_args << "--bintray-repo=#{repo}" if repo
mirror_args << "--no-publish" unless publish mirror_args << "--no-publish" unless publish
@ -233,7 +232,7 @@ module Homebrew
_, user, repo, pr = *url_match _, user, repo, pr = *url_match
odie "Not a GitHub pull request: #{arg}" unless pr odie "Not a GitHub pull request: #{arg}" unless pr
check_branch tap.path, "master" check_branch tap.path, "master", args: args
ohai "Fetching #{tap} pull request ##{pr}" ohai "Fetching #{tap} pull request ##{pr}"
Dir.mktmpdir pr do |dir| Dir.mktmpdir pr do |dir|
@ -259,8 +258,8 @@ module Homebrew
next if args.no_upload? next if args.no_upload?
upload_args = ["pr-upload"] upload_args = ["pr-upload"]
upload_args << "--debug" if Homebrew.args.debug? upload_args << "--debug" if args.debug?
upload_args << "--verbose" if Homebrew.args.verbose? upload_args << "--verbose" if args.verbose?
upload_args << "--no-publish" if args.no_publish? upload_args << "--no-publish" if args.no_publish?
upload_args << "--dry-run" if args.dry_run? upload_args << "--dry-run" if args.dry_run?
upload_args << "--warn-on-upload-failure" if args.warn_on_upload_failure? upload_args << "--warn-on-upload-failure" if args.warn_on_upload_failure?

View File

@ -27,8 +27,6 @@ module Homebrew
description: "Upload to the specified Bintray organisation (default: `homebrew`)." description: "Upload to the specified Bintray organisation (default: `homebrew`)."
flag "--root-url=", flag "--root-url=",
description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default." description: "Use the specified <URL> as the root of the bottle's URL instead of Homebrew's default."
switch :verbose
switch :debug
end end
end end

View File

@ -37,8 +37,7 @@ module Homebrew
description: "Do not warn if pulling to a branch besides master (useful for testing)." description: "Do not warn if pulling to a branch besides master (useful for testing)."
switch "--no-pbcopy", switch "--no-pbcopy",
description: "Do not copy anything to the system clipboard." description: "Do not copy anything to the system clipboard."
switch :verbose
switch :debug
min_named 1 min_named 1
end end
end end
@ -48,7 +47,7 @@ module Homebrew
odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase" odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase"
pull_args.parse args = pull_args.parse
# Passthrough Git environment variables for e.g. git am # Passthrough Git environment variables for e.g. git am
Utils.set_git_name_email!(author: false, committer: true) Utils.set_git_name_email!(author: false, committer: true)

View File

@ -21,7 +21,7 @@ module Homebrew
end end
def release_notes def release_notes
release_notes_args.parse args = release_notes_args.parse
previous_tag = args.named.first previous_tag = args.named.first
previous_tag ||= Utils.popen_read( previous_tag ||= Utils.popen_read(

View File

@ -17,8 +17,6 @@ module Homebrew
description: "Load a library using `require`." description: "Load a library using `require`."
switch "-e", switch "-e",
description: "Execute the given text string as a script." description: "Execute the given text string as a script."
switch :verbose
switch :debug
end end
end end

View File

@ -20,8 +20,7 @@ module Homebrew
EOS EOS
flag "--env=", flag "--env=",
description: "Use the standard `PATH` instead of superenv's when `std` is passed." description: "Use the standard `PATH` instead of superenv's when `std` is passed."
switch :verbose
switch :debug
max_named 0 max_named 0
end end
end end

View File

@ -29,14 +29,13 @@ module Homebrew
comma_array "--except-cops", comma_array "--except-cops",
description: "Specify a comma-separated <cops> list to skip checking for violations of the "\ description: "Specify a comma-separated <cops> list to skip checking for violations of the "\
"listed RuboCop cops." "listed RuboCop cops."
switch :verbose
switch :debug
conflicts "--only-cops", "--except-cops" conflicts "--only-cops", "--except-cops"
end end
end end
def style def style
style_args.parse args = style_args.parse
target = if args.no_named? target = if args.no_named?
nil nil

View File

@ -13,14 +13,13 @@ module Homebrew
Generate the template files for a new tap. Generate the template files for a new tap.
EOS EOS
switch :verbose
switch :debug
named 1 named 1
end end
end end
def tap_new def tap_new
tap_new_args.parse args = tap_new_args.parse
tap_name = args.named.first tap_name = args.named.first
tap = Tap.fetch(args.named.first) tap = Tap.fetch(args.named.first)

View File

@ -27,15 +27,14 @@ module Homebrew
description: "Retain the temporary files created for the test." description: "Retain the temporary files created for the test."
switch "--retry", switch "--retry",
description: "Retry if a testing fails." description: "Retry if a testing fails."
switch :verbose
switch :debug
conflicts "--devel", "--HEAD" conflicts "--devel", "--HEAD"
min_named :formula min_named :formula
end end
end end
def test def test
test_args.parse args = test_args.parse
require "formula_assertions" require "formula_assertions"
require "formula_free_port" require "formula_free_port"
@ -110,7 +109,7 @@ module Homebrew
end end
end end
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
retry if retry_test?(f) retry if retry_test?(f, args: args)
ofail "#{f.full_name}: failed" ofail "#{f.full_name}: failed"
puts e, e.backtrace puts e, e.backtrace
ensure ensure
@ -119,7 +118,7 @@ module Homebrew
end end
end end
def retry_test?(f) def retry_test?(f, args:)
@test_failed ||= Set.new @test_failed ||= Set.new
if args.retry? && @test_failed.add?(f) if args.retry? && @test_failed.add?(f)
oh1 "Testing #{f.full_name} (again)" oh1 "Testing #{f.full_name} (again)"

View File

@ -29,14 +29,13 @@ module Homebrew
"specific line." "specific line."
flag "--seed=", flag "--seed=",
description: "Randomise tests with the specified <value> instead of a random seed." description: "Randomise tests with the specified <value> instead of a random seed."
switch :verbose
switch :debug
max_named 0 max_named 0
end end
end end
def tests def tests
tests_args.parse args = tests_args.parse
Homebrew.install_bundler_gems! Homebrew.install_bundler_gems!
gem_user_dir = Gem.user_dir gem_user_dir = Gem.user_dir

View File

@ -24,15 +24,14 @@ module Homebrew
"patches for the software." "patches for the software."
switch "-f", "--force", switch "-f", "--force",
description: "Overwrite the destination directory if it already exists." description: "Overwrite the destination directory if it already exists."
switch :verbose
switch :debug
conflicts "--git", "--patch" conflicts "--git", "--patch"
min_named :formula min_named :formula
end end
end end
def unpack def unpack
unpack_args.parse args = unpack_args.parse
formulae = args.formulae formulae = args.formulae
@ -56,12 +55,13 @@ module Homebrew
oh1 "Unpacking #{Formatter.identifier(f.full_name)} to: #{stage_dir}" oh1 "Unpacking #{Formatter.identifier(f.full_name)} to: #{stage_dir}"
ENV["VERBOSE"] = "1" # show messages about tar # show messages about tar
with_env VERBOSE: "1" do
f.brew do f.brew do
f.patch if args.patch? f.patch if args.patch?
cp_r getwd, stage_dir, preserve: true cp_r getwd, stage_dir, preserve: true
end end
ENV["VERBOSE"] = nil end
next unless args.git? next unless args.git?

View File

@ -26,7 +26,7 @@ module Homebrew
end end
def update_license_data def update_license_data
update_license_data_args.parse args = update_license_data_args.parse
ohai "Updating SPDX license data..." ohai "Updating SPDX license data..."
latest_tag = GitHub.open_api(SPDX_API_URL)["tag_name"] latest_tag = GitHub.open_api(SPDX_API_URL)["tag_name"]

View File

@ -21,14 +21,13 @@ module Homebrew
description: "Use the specified <commit> as the start commit." description: "Use the specified <commit> as the start commit."
flag "--before=", flag "--before=",
description: "Use the commit at the specified <date> as the start commit." description: "Use the commit at the specified <date> as the start commit."
switch :verbose
switch :debug
max_named 0 max_named 0
end end
end end
def update_test def update_test
update_test_args.parse args = update_test_args.parse
ENV["HOMEBREW_UPDATE_TEST"] = "1" ENV["HOMEBREW_UPDATE_TEST"] = "1"

View File

@ -13,7 +13,7 @@ module Homebrew
Install and commit Homebrew's vendored gems. Install and commit Homebrew's vendored gems.
EOS EOS
switch :debug
max_named 0 max_named 0
end end
end end

View File

@ -1461,14 +1461,16 @@ class Formula
# @private # @private
def self.each def self.each
files.each do |file| files.each do |file|
yield Formulary.factory(file) yield begin
rescue => e Formulary.factory(file)
rescue FormulaUnavailableError => e
# Don't let one broken formula break commands. But do complain. # Don't let one broken formula break commands. But do complain.
onoe "Failed to import: #{file}" onoe "Failed to import: #{file}"
puts e puts e
next next
end end
end end
end
# Clear cache of .racks # Clear cache of .racks
def self.clear_racks_cache def self.clear_racks_cache

View File

@ -82,7 +82,7 @@ module Homebrew
end end
def args def args
@args ||= CLI::Args.new(set_default_args: true) @args ||= CLI::Args.new
end end
def messages def messages

View File

@ -40,30 +40,30 @@ module Homebrew
module Help module Help
module_function module_function
def help(cmd = nil, flags = {}) def help(cmd = nil, empty_argv: false, usage_error: nil)
# Resolve command aliases and find file containing the implementation. if cmd.nil?
path = Commands.path(cmd) if cmd
# Display command-specific (or generic) help in response to `UsageError`.
if (error_message = flags[:usage_error])
$stderr.puts path ? command_help(cmd, path) : HOMEBREW_HELP
$stderr.puts
onoe error_message
exit 1
end
# Handle `brew` (no arguments). # Handle `brew` (no arguments).
if flags[:empty_argv] if empty_argv
$stderr.puts HOMEBREW_HELP $stderr.puts HOMEBREW_HELP
exit 1 exit 1
end end
# Handle `brew (-h|--help|--usage|-?|help)` (no other arguments). # Handle `brew (-h|--help|--usage|-?|help)` (no other arguments).
if cmd.nil?
puts HOMEBREW_HELP puts HOMEBREW_HELP
exit 0 exit 0
end end
# Resolve command aliases and find file containing the implementation.
path = Commands.path(cmd)
# Display command-specific (or generic) help in response to `UsageError`.
if usage_error
$stderr.puts path ? command_help(cmd, path) : HOMEBREW_HELP
$stderr.puts
onoe usage_error
exit 1
end
# Resume execution in `brew.rb` for unknown commands. # Resume execution in `brew.rb` for unknown commands.
return if path.nil? return if path.nil?
@ -95,6 +95,8 @@ module Homebrew
cmd_parser = CLI::Parser.from_cmd_path(path) cmd_parser = CLI::Parser.from_cmd_path(path)
return unless cmd_parser return unless cmd_parser
# Try parsing arguments here in order to show formula options in help output.
cmd_parser.parse(Homebrew.args.remaining, ignore_invalid_options: true)
cmd_parser.generate_help_text cmd_parser.generate_help_text
end end

View File

@ -163,6 +163,7 @@ false:
- ./dev-cmd/tests.rb - ./dev-cmd/tests.rb
- ./dev-cmd/unpack.rb - ./dev-cmd/unpack.rb
- ./dev-cmd/update-license-data.rb - ./dev-cmd/update-license-data.rb
- ./dev-cmd/update-python-resources.rb
- ./dev-cmd/update-test.rb - ./dev-cmd/update-test.rb
- ./dev-cmd/vendor-gems.rb - ./dev-cmd/vendor-gems.rb
- ./development_tools.rb - ./development_tools.rb
@ -268,6 +269,7 @@ false:
- ./test/ENV_spec.rb - ./test/ENV_spec.rb
- ./test/bintray_spec.rb - ./test/bintray_spec.rb
- ./test/bottle_publisher_spec.rb - ./test/bottle_publisher_spec.rb
- ./test/cask_dependent_spec.rb
- ./test/cask/artifact/alt_target_spec.rb - ./test/cask/artifact/alt_target_spec.rb
- ./test/cask/artifact/app_spec.rb - ./test/cask/artifact/app_spec.rb
- ./test/cask/artifact/binary_spec.rb - ./test/cask/artifact/binary_spec.rb
@ -823,11 +825,13 @@ false:
- ./test/version_spec.rb - ./test/version_spec.rb
- ./unpack_strategy/uncompressed.rb - ./unpack_strategy/uncompressed.rb
- ./utils/gems.rb - ./utils/gems.rb
- ./utils/pypi.rb
- ./version.rb - ./version.rb
true: true:
- ./build_options.rb - ./build_options.rb
- ./cache_store.rb - ./cache_store.rb
- ./cask_dependent.rb
- ./cask/cache.rb - ./cask/cache.rb
- ./cask/denylist.rb - ./cask/denylist.rb
- ./cask/macos.rb - ./cask/macos.rb

View File

@ -15,5 +15,7 @@ module Homebrew::CLI
def build_from_source?; end def build_from_source?; end
def named_args; end def named_args; end
def force_bottle?; end
end end
end end

View File

@ -1,6 +0,0 @@
# This file is autogenerated. Do not edit it by hand. Regenerate it with:
# tapioca sync --exclude json
# typed: true

View File

@ -0,0 +1,7 @@
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `codecov` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true

View File

@ -0,0 +1,7 @@
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `commander` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true

View File

@ -0,0 +1,7 @@
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `highline` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true

View File

@ -0,0 +1,7 @@
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `parlour` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true

View File

@ -1,5 +1,6 @@
# This file is autogenerated. Do not edit it by hand. Regenerate it with: # DO NOT EDIT MANUALLY
# tapioca sync --exclude json # This is an autogenerated file for types exported from the `patchelf` gem.
# Please instead update this file by running `tapioca sync --exclude json`.
# typed: true # typed: true
@ -10,15 +11,17 @@ module PatchELF::Helper
private private
def aligndown(val, align = _); end def aligndown(val, align = T.unsafe(nil)); end
def alignup(val, align = _); end def alignup(val, align = T.unsafe(nil)); end
def color_enabled?; end def color_enabled?; end
def colorize(str, type); end def colorize(str, type); end
def self.aligndown(val, align = _); end class << self
def self.alignup(val, align = _); end def aligndown(val, align = T.unsafe(nil)); end
def self.color_enabled?; end def alignup(val, align = T.unsafe(nil)); end
def self.colorize(str, type); end def color_enabled?; end
def colorize(str, type); end
end
end end
PatchELF::Helper::COLOR_CODE = T.let(T.unsafe(nil), Hash) PatchELF::Helper::COLOR_CODE = T.let(T.unsafe(nil), Hash)
@ -33,9 +36,11 @@ module PatchELF::Logger
def info(msg); end def info(msg); end
def warn(msg); end def warn(msg); end
def self.error(msg); end class << self
def self.info(msg); end def error(msg); end
def self.warn(msg); end def info(msg); end
def warn(msg); end
end
end end
class PatchELF::MM class PatchELF::MM
@ -51,10 +56,10 @@ class PatchELF::MM
private private
def abnormal_elf(msg); end def abnormal_elf(msg); end
def extend_backward(seg, size = _); end def extend_backward(seg, size = T.unsafe(nil)); end
def extend_forward(seg, size = _); end def extend_forward(seg, size = T.unsafe(nil)); end
def fgap_method; end def fgap_method; end
def find_gap(check_sz: _); end def find_gap(check_sz: T.unsafe(nil)); end
def invoke_callbacks(seg, start); end def invoke_callbacks(seg, start); end
def load_segments; end def load_segments; end
def mgap_method; end def mgap_method; end
@ -73,7 +78,7 @@ class PatchELF::PatchError < ::ELFTools::ELFError
end end
class PatchELF::Patcher class PatchELF::Patcher
def initialize(filename, logging: _); end def initialize(filename, on_error: T.unsafe(nil), logging: T.unsafe(nil)); end
def add_needed(need); end def add_needed(need); end
def elf; end def elf; end
@ -87,7 +92,7 @@ class PatchELF::Patcher
def rpath=(rpath); end def rpath=(rpath); end
def runpath; end def runpath; end
def runpath=(runpath); end def runpath=(runpath); end
def save(out_file = _); end def save(out_file = T.unsafe(nil)); end
def soname; end def soname; end
def soname=(name); end def soname=(name); end
def use_rpath!; end def use_rpath!; end
@ -97,9 +102,9 @@ class PatchELF::Patcher
def dirty?; end def dirty?; end
def dynamic_or_log; end def dynamic_or_log; end
def interpreter_; end def interpreter_; end
def log_or_raise(msg, exception = _); end def log_or_raise(msg, exception = T.unsafe(nil)); end
def needed_; end def needed_; end
def runpath_(rpath_sym = _); end def runpath_(rpath_sym = T.unsafe(nil)); end
def soname_; end def soname_; end
def tag_name_or_log(type, log_msg); end def tag_name_or_log(type, log_msg); end
end end
@ -122,7 +127,7 @@ class PatchELF::Saver
def patch_interpreter; end def patch_interpreter; end
def patch_needed; end def patch_needed; end
def patch_out(out_file); end def patch_out(out_file); end
def patch_runpath(sym = _); end def patch_runpath(sym = T.unsafe(nil)); end
def patch_soname; end def patch_soname; end
def reg_str_table(str, &block); end def reg_str_table(str, &block); end
def section_header(name); end def section_header(name); end

View File

@ -13549,6 +13549,94 @@ module ParallelTests
WINDOWS = ::T.let(nil, ::T.untyped) WINDOWS = ::T.let(nil, ::T.untyped)
end end
class Parlour::ConflictResolver
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Parlour::Debugging::Tree
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Parlour::Debugging
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::DetachedRbiGenerator
def detached!(*args, &blk); end
end
class Parlour::DetachedRbiGenerator
end
class Parlour::ParseError
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::Plugin
extend ::T::Private::Abstract::Hooks
extend ::T::InterfaceWrapper::Helpers
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator::Namespace
def create_attr(*args, &blk); end
end
class Parlour::RbiGenerator::Options
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator::Parameter
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator::RbiObject
def add_comments(*args, &blk); end
end
class Parlour::RbiGenerator::RbiObject
extend ::T::Private::Abstract::Hooks
extend ::T::InterfaceWrapper::Helpers
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator::StructProp
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::RbiGenerator
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Parlour::TypeLoader
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::TypeParser::IntermediateSig
def self.inherited(s); end
end
class Parlour::TypeParser::NodePath
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Parlour::TypeParser
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
ParseError = Racc::ParseError ParseError = Racc::ParseError
Parser::CurrentRuby = Parser::Ruby26 Parser::CurrentRuby = Parser::Ruby26
@ -18883,14 +18971,6 @@ end
module RSpec::Its module RSpec::Its
end end
class RSpec::Mocks::AnyInstance::Recorder
include ::T::CompatibilityPatches::RSpecCompatibility::RecorderExtensions
end
class RSpec::Mocks::MethodDouble
include ::T::CompatibilityPatches::RSpecCompatibility::MethodDoubleExtensions
end
class RSpec::Retry class RSpec::Retry
def attempts(); end def attempts(); end
@ -21598,7 +21678,6 @@ module Stdenv
def O3(); end def O3(); end
def Os(); end def Os(); end
end end
class String class String
@ -21895,7 +21974,6 @@ module Superenv
def O3(); end def O3(); end
def Os(); end def Os(); end
end end
class SynchronizedDelegator class SynchronizedDelegator
@ -22566,12 +22644,16 @@ end
class Tapioca::Cli class Tapioca::Cli
include ::Thor::Actions include ::Thor::Actions
def dsl(*constants); end
def generate(*gems); end def generate(*gems); end
def generator(); end def generator(); end
def init(); end def init(); end
def require(); end
def sync(); end def sync(); end
def todo(); end def todo(); end
@ -22583,6 +22665,64 @@ end
module Tapioca::Compilers module Tapioca::Compilers
end end
module Tapioca::Compilers::Dsl
end
class Tapioca::Compilers::Dsl::Base
def decorate(*args, &blk); end
def gather_constants(*args, &blk); end
def handles?(*args, &blk); end
def initialize(*args, &blk); end
def processable_constants(*args, &blk); end
SPECIAL_METHOD_NAMES = ::T.let(nil, ::T.untyped)
end
class Tapioca::Compilers::Dsl::Base
extend ::T::Sig
extend ::T::Helpers
extend ::T::Private::Abstract::Hooks
extend ::T::InterfaceWrapper::Helpers
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Tapioca::Compilers::Dsl
end
class Tapioca::Compilers::DslCompiler
def error_handler(*args, &blk); end
def generators(*args, &blk); end
def initialize(*args, &blk); end
def requested_constants(*args, &blk); end
def run(*args, &blk); end
end
class Tapioca::Compilers::DslCompiler
extend ::T::Sig
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
class Tapioca::Compilers::RequiresCompiler
def compile(*args, &blk); end
def initialize(*args, &blk); end
end
class Tapioca::Compilers::RequiresCompiler
extend ::T::Sig
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
end
module Tapioca::Compilers::Sorbet module Tapioca::Compilers::Sorbet
SORBET = ::T.let(nil, ::T.untyped) SORBET = ::T.let(nil, ::T.untyped)
end end
@ -22607,6 +22747,7 @@ class Tapioca::Compilers::SymbolTable::SymbolGenerator
def initialize(*args, &blk); end def initialize(*args, &blk); end
IGNORED_SYMBOLS = ::T.let(nil, ::T.untyped) IGNORED_SYMBOLS = ::T.let(nil, ::T.untyped)
SPECIAL_METHOD_NAMES = ::T.let(nil, ::T.untyped) SPECIAL_METHOD_NAMES = ::T.let(nil, ::T.untyped)
TYPE_PARAMETER_MATCHER = ::T.let(nil, ::T.untyped)
end end
class Tapioca::Compilers::SymbolTable::SymbolGenerator class Tapioca::Compilers::SymbolTable::SymbolGenerator
@ -22663,6 +22804,8 @@ class Tapioca::Config
def generate_command(); end def generate_command(); end
def generators(); end
def initialize(*args, &blk); end def initialize(*args, &blk); end
def outdir(); end def outdir(); end
@ -22676,13 +22819,16 @@ class Tapioca::Config
def todos_path(); end def todos_path(); end
def typed_overrides(); end def typed_overrides(); end
CONFIG_FILE_PATH = ::T.let(nil, ::T.untyped) DEFAULT_DSLDIR = ::T.let(nil, ::T.untyped)
DEFAULT_OUTDIR = ::T.let(nil, ::T.untyped) DEFAULT_GEMDIR = ::T.let(nil, ::T.untyped)
DEFAULT_OVERRIDES = ::T.let(nil, ::T.untyped) DEFAULT_OVERRIDES = ::T.let(nil, ::T.untyped)
DEFAULT_POSTREQUIRE = ::T.let(nil, ::T.untyped) DEFAULT_POSTREQUIRE = ::T.let(nil, ::T.untyped)
DEFAULT_RBIDIR = ::T.let(nil, ::T.untyped) DEFAULT_RBIDIR = ::T.let(nil, ::T.untyped)
DEFAULT_TODOSPATH = ::T.let(nil, ::T.untyped) DEFAULT_TODOSPATH = ::T.let(nil, ::T.untyped)
SORBET_CONFIG = ::T.let(nil, ::T.untyped) SORBET_CONFIG = ::T.let(nil, ::T.untyped)
SORBET_PATH = ::T.let(nil, ::T.untyped)
TAPIOCA_CONFIG = ::T.let(nil, ::T.untyped)
TAPIOCA_PATH = ::T.let(nil, ::T.untyped)
end end
class Tapioca::Config class Tapioca::Config
@ -22757,8 +22903,12 @@ class Tapioca::Gemfile
end end
class Tapioca::Generator class Tapioca::Generator
def build_dsl(*args, &blk); end
def build_gem_rbis(*args, &blk); end def build_gem_rbis(*args, &blk); end
def build_requires(*args, &blk); end
def build_todos(*args, &blk); end def build_todos(*args, &blk); end
def config(*args, &blk); end def config(*args, &blk); end
@ -22778,6 +22928,8 @@ class Tapioca::Loader
def initialize(*args, &blk); end def initialize(*args, &blk); end
def load_bundle(*args, &blk); end def load_bundle(*args, &blk); end
def load_rails(*args, &blk); end
end end
class Tapioca::Loader class Tapioca::Loader
@ -22786,6 +22938,23 @@ class Tapioca::Loader
extend ::T::Private::Methods::SingletonMethodHooks extend ::T::Private::Methods::SingletonMethodHooks
end end
class Tapioca::SorbetConfig
def ignore(); end
def initialize(*args, &blk); end
def paths(*args, &blk); end
end
class Tapioca::SorbetConfig
extend ::T::Sig
extend ::T::Private::Methods::MethodHooks
extend ::T::Private::Methods::SingletonMethodHooks
def self.parse_file(*args, &blk); end
def self.parse_string(*args, &blk); end
end
module Tapioca module Tapioca
end end

View File

@ -6,7 +6,6 @@ describe Homebrew::CLI::Parser do
describe "test switch options" do describe "test switch options" do
subject(:parser) { subject(:parser) {
described_class.new do described_class.new do
switch :verbose, description: "Flag for verbosity"
switch "--more-verbose", description: "Flag for higher verbosity" switch "--more-verbose", description: "Flag for higher verbosity"
switch "--pry", env: :pry switch "--pry", env: :pry
end end
@ -16,27 +15,34 @@ describe Homebrew::CLI::Parser do
allow(Homebrew::EnvConfig).to receive(:pry?).and_return(true) allow(Homebrew::EnvConfig).to receive(:pry?).and_return(true)
end end
context "when `ignore_invalid_options` is true" do
it "passes through invalid options" do
args = parser.parse(["-v", "named-arg", "--not-a-valid-option"], ignore_invalid_options: true)
expect(args.remaining).to eq ["named-arg", "--not-a-valid-option"]
expect(args.named_args).to be_empty
end
end
it "parses short option" do it "parses short option" do
parser.parse(["-v"]) args = parser.parse(["-v"])
expect(Homebrew.args).to be_verbose expect(args).to be_verbose
end end
it "parses a single valid option" do it "parses a single valid option" do
parser.parse(["--verbose"]) args = parser.parse(["--verbose"])
expect(Homebrew.args).to be_verbose expect(args).to be_verbose
end end
it "parses a valid option along with few unnamed args" do it "parses a valid option along with few unnamed args" do
args = %w[--verbose unnamed args] args = parser.parse(%w[--verbose unnamed args])
parser.parse(args) expect(args).to be_verbose
expect(Homebrew.args).to be_verbose expect(args.named).to eq %w[unnamed args]
expect(args).to eq %w[--verbose unnamed args]
end end
it "parses a single option and checks other options to be nil" do it "parses a single option and checks other options to be nil" do
parser.parse(["--verbose"]) args = parser.parse(["--verbose"])
expect(Homebrew.args).to be_verbose expect(args).to be_verbose
expect(Homebrew.args.more_verbose?).to be nil expect(args.more_verbose?).to be nil
end end
it "raises an exception and outputs help text when an invalid option is passed" do it "raises an exception and outputs help text when an invalid option is passed" do
@ -45,13 +51,8 @@ describe Homebrew::CLI::Parser do
end end
it "maps environment var to an option" do it "maps environment var to an option" do
parser.parse([]) args = parser.parse([])
expect(Homebrew.args.pry?).to be true expect(args.pry?).to be true
end
it ":verbose with custom description" do
_, _, _, desc = parser.processed_options.find { |short, _| short == "-v" }
expect(desc).to eq "Flag for verbosity"
end end
end end
@ -64,8 +65,8 @@ describe Homebrew::CLI::Parser do
} }
it "parses a long flag option with its argument" do it "parses a long flag option with its argument" do
parser.parse(["--filename=random.txt"]) args = parser.parse(["--filename=random.txt"])
expect(Homebrew.args.filename).to eq "random.txt" expect(args.filename).to eq "random.txt"
end end
it "raises an exception when a flag's required value is not passed" do it "raises an exception when a flag's required value is not passed" do
@ -73,8 +74,8 @@ describe Homebrew::CLI::Parser do
end end
it "parses a comma array flag option" do it "parses a comma array flag option" do
parser.parse(["--files=random1.txt,random2.txt"]) args = parser.parse(["--files=random1.txt,random2.txt"])
expect(Homebrew.args.files).to eq %w[random1.txt random2.txt] expect(args.files).to eq %w[random1.txt random2.txt]
end end
end end
@ -86,9 +87,9 @@ describe Homebrew::CLI::Parser do
} }
it "parses a short flag option with its argument" do it "parses a short flag option with its argument" do
parser.parse(["--filename=random.txt"]) args = parser.parse(["--filename=random.txt"])
expect(Homebrew.args.filename).to eq "random.txt" expect(args.filename).to eq "random.txt"
expect(Homebrew.args.f).to eq "random.txt" expect(args.f).to eq "random.txt"
end end
end end
@ -118,14 +119,14 @@ describe Homebrew::CLI::Parser do
end end
it "raises no exception" do it "raises no exception" do
parser.parse(["--flag1=flag1", "--flag2=flag2"]) args = parser.parse(["--flag1=flag1", "--flag2=flag2"])
expect(Homebrew.args.flag1).to eq "flag1" expect(args.flag1).to eq "flag1"
expect(Homebrew.args.flag2).to eq "flag2" expect(args.flag2).to eq "flag2"
end end
it "raises no exception for optional dependency" do it "raises no exception for optional dependency" do
parser.parse(["--flag3=flag3"]) args = parser.parse(["--flag3=flag3"])
expect(Homebrew.args.flag3).to eq "flag3" expect(args.flag3).to eq "flag3"
end end
end end
@ -169,22 +170,22 @@ describe Homebrew::CLI::Parser do
end end
it "raises no exception" do it "raises no exception" do
parser.parse(["--switch-a", "--switch-c"]) args = parser.parse(["--switch-a", "--switch-c"])
expect(Homebrew.args.switch_a?).to be true expect(args.switch_a?).to be true
expect(Homebrew.args.switch_c?).to be true expect(args.switch_c?).to be true
end end
it "raises no exception for optional dependency" do it "raises no exception for optional dependency" do
parser.parse(["--switch-b"]) args = parser.parse(["--switch-b"])
expect(Homebrew.args.switch_b?).to be true expect(args.switch_b?).to be true
end end
it "prioritizes cli arguments over env vars when they conflict" do it "prioritizes cli arguments over env vars when they conflict" do
allow(Homebrew::EnvConfig).to receive(:switch_a?).and_return(true) allow(Homebrew::EnvConfig).to receive(:switch_a?).and_return(true)
allow(Homebrew::EnvConfig).to receive(:switch_b?).and_return(false) allow(Homebrew::EnvConfig).to receive(:switch_b?).and_return(false)
parser.parse(["--switch-b"]) args = parser.parse(["--switch-b"])
expect(Homebrew.args.switch_a).to be_falsy expect(args.switch_a).to be_falsy
expect(Homebrew.args).to be_switch_b expect(args).to be_switch_b
end end
it "raises an exception on constraint violation when both are env vars" do it "raises an exception on constraint violation when both are env vars" do
@ -214,38 +215,32 @@ describe Homebrew::CLI::Parser do
switch "--foo" switch "--foo"
flag "--bar" flag "--bar"
switch "-s" switch "-s"
switch :verbose
end end
} }
it "#options_only" do it "#options_only" do
parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"]) args = parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"])
expect(Homebrew.args.options_only).to eq %w[--foo --bar=value -s --verbose] expect(args.options_only).to eq %w[--verbose --foo --bar=value -s]
end end
it "#flags_only" do it "#flags_only" do
parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"]) args = parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"])
expect(Homebrew.args.flags_only).to eq %w[--foo --bar=value --verbose] expect(args.flags_only).to eq %w[--verbose --foo --bar=value]
end
it "#passthrough" do
parser.parse(["--foo", "--bar=value", "-v", "-s", "a", "b", "cdefg"])
expect(Homebrew.args.passthrough).to eq %w[--foo --bar=value -s]
end end
it "#formulae raises an error when a Formula is unavailable" do it "#formulae raises an error when a Formula is unavailable" do
parser.parse(["mxcl"]) args = parser.parse(["mxcl"])
expect { Homebrew.args.formulae }.to raise_error FormulaUnavailableError expect { args.formulae }.to raise_error FormulaUnavailableError
end end
it "#formulae returns an empty array when there are no Formulae" do it "#formulae returns an empty array when there are no Formulae" do
parser.parse([]) args = parser.parse([])
expect(Homebrew.args.formulae).to be_empty expect(args.formulae).to be_empty
end end
it "#casks returns an empty array when there are no matching casks" do it "#casks returns an empty array when there are no matching casks" do
parser.parse([]) args = parser.parse([])
expect(Homebrew.args.casks).to eq [] expect(args.casks).to eq []
end end
context "kegs" do context "kegs" do
@ -255,24 +250,24 @@ describe Homebrew::CLI::Parser do
end end
it "when there are matching kegs returns an array of Kegs" do it "when there are matching kegs returns an array of Kegs" do
parser.parse(["mxcl"]) args = parser.parse(["mxcl"])
expect(Homebrew.args.kegs.length).to eq 1 expect(args.kegs.length).to eq 1
end end
it "when there are no matching kegs returns an array of Kegs" do it "when there are no matching kegs returns an array of Kegs" do
parser.parse([]) args = parser.parse([])
expect(Homebrew.args.kegs).to be_empty expect(args.kegs).to be_empty
end end
end end
it "#named returns an array of non-option arguments" do it "#named returns an array of non-option arguments" do
parser.parse(["foo", "-v", "-s"]) args = parser.parse(["foo", "-v", "-s"])
expect(Homebrew.args.named).to eq ["foo"] expect(args.named).to eq ["foo"]
end end
it "#named returns an empty array when there are no named arguments" do it "#named returns an empty array when there are no named arguments" do
parser.parse([]) args = parser.parse([])
expect(Homebrew.args.named).to be_empty expect(args.named).to be_empty
end end
end end
end end

View File

@ -14,7 +14,8 @@ shared_examples "parseable arguments" do
it "can parse arguments" do it "can parse arguments" do
require "dev-cmd/#{command_name}" unless require? "cmd/#{command_name}" require "dev-cmd/#{command_name}" unless require? "cmd/#{command_name}"
expect { Homebrew.send(method_name).parse({}, allow_no_named_args: true) } parser = Homebrew.public_send(method_name)
.not_to raise_error
expect(parser).to respond_to(:parse)
end end
end end

View File

@ -50,7 +50,7 @@ describe FormulaInstaller do
specify "basic bottle install" do specify "basic bottle install" do
allow(DevelopmentTools).to receive(:installed?).and_return(false) allow(DevelopmentTools).to receive(:installed?).and_return(false)
Homebrew.install_args.parse("testball_bottle") Homebrew.install_args.parse(["testball_bottle"])
temporarily_install_bottle(TestballBottle.new) do |f| temporarily_install_bottle(TestballBottle.new) do |f|
# Copied directly from formula_installer_spec.rb # Copied directly from formula_installer_spec.rb
# as we expect the same behavior. # as we expect the same behavior.

View File

@ -7,7 +7,21 @@ module PyPI
@pipgrip_installed = nil @pipgrip_installed = nil
# Get name, url, and version for a given pypi package def url_to_pypi_package_name(url)
return unless url.start_with? PYTHONHOSTED_URL_PREFIX
File.basename(url).match(/^(.+)-[a-z\d.]+$/)[1]
end
def update_pypi_url(url, version)
package = url_to_pypi_package_name url
return if package.nil?
_, url = get_pypi_info(package, version)
url
end
# Get name, url and sha256 for a given pypi package
def get_pypi_info(package, version) def get_pypi_info(package, version)
metadata_url = "https://pypi.org/pypi/#{package}/#{version}/json" metadata_url = "https://pypi.org/pypi/#{package}/#{version}/json"
out, _, status = curl_output metadata_url, "--location" out, _, status = curl_output metadata_url, "--location"
@ -21,18 +35,17 @@ module PyPI
end end
sdist = json["urls"].find { |url| url["packagetype"] == "sdist" } sdist = json["urls"].find { |url| url["packagetype"] == "sdist" }
return json["info"]["name"] if sdist.nil?
[json["info"]["name"], sdist["url"], sdist["digests"]["sha256"]] [json["info"]["name"], sdist["url"], sdist["digests"]["sha256"]]
end end
def update_python_resources!(formula, version = nil, print_only: false, silent: false, def update_python_resources!(formula, version = nil, print_only: false, silent: false,
ignore_non_pypi_packages: false) ignore_non_pypi_packages: false)
@pipgrip_installed ||= Formula["pipgrip"].any_version_installed?
odie '"pipgrip" must be installed (`brew install pipgrip`)' unless @pipgrip_installed
# PyPI package name isn't always the same as the formula name. Try to infer from the URL. # PyPI package name isn't always the same as the formula name. Try to infer from the URL.
pypi_name = if formula.stable.url.start_with?(PYTHONHOSTED_URL_PREFIX) pypi_name = if formula.stable.url.start_with?(PYTHONHOSTED_URL_PREFIX)
File.basename(formula.stable.url).match(/^(.+)-[a-z\d.]+$/)[1] url_to_pypi_package_name formula.stable.url
else else
formula.name formula.name
end end
@ -52,12 +65,17 @@ module PyPI
odie "\"#{formula.name}\" contains non-PyPI resources. Please update the resources manually." odie "\"#{formula.name}\" contains non-PyPI resources. Please update the resources manually."
end end
@pipgrip_installed ||= Formula["pipgrip"].any_version_installed?
odie '"pipgrip" must be installed (`brew install pipgrip`)' unless @pipgrip_installed
ohai "Retrieving PyPI dependencies for \"#{pypi_name}==#{version}\"" if !print_only && !silent ohai "Retrieving PyPI dependencies for \"#{pypi_name}==#{version}\"" if !print_only && !silent
pipgrip_output = Utils.popen_read Formula["pipgrip"].bin/"pipgrip", "--json", "#{pypi_name}==#{version}" pipgrip_output = Utils.popen_read Formula["pipgrip"].bin/"pipgrip", "--json", "--no-cache-dir",
"#{pypi_name}==#{version}"
unless $CHILD_STATUS.success? unless $CHILD_STATUS.success?
odie <<~EOS odie <<~EOS
Unable to determine dependencies for \"#{pypi_name}\" because of a failure when running Unable to determine dependencies for \"#{pypi_name}\" because of a failure when running
`pipgrip --json #{pypi_name}==#{version}`. Please update the resources for \"#{formula.name}\" manually. `pipgrip --json --no-cache-dir #{pypi_name}==#{version}`.
Please update the resources for \"#{formula.name}\" manually.
EOS EOS
end end

View File

@ -312,8 +312,10 @@ no formula is provided.
Also print diffstat from commit. Also print diffstat from commit.
* `--oneline`: * `--oneline`:
Print only one line per commit. Print only one line per commit.
* `-1`, `--max-count`: * `-1`:
Print only one or a specified number of commits. Print only one commit.
* `-n`, `--max-count`:
Print only a specified number of commits.
### `migrate` [*`options`*] *`formula`* ### `migrate` [*`options`*] *`formula`*
@ -525,6 +527,8 @@ Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1)
Use `git merge` to apply updates (rather than `git rebase`). Use `git merge` to apply updates (rather than `git rebase`).
* `--preinstall`: * `--preinstall`:
Run on auto-updates (e.g. before `brew install`). Skips some slower steps. Run on auto-updates (e.g. before `brew install`). Skips some slower steps.
* `-f`, `--force`:
Always do a slower, full update check (even if unnecessary).
### `update-reset` [*`repository`*] ### `update-reset` [*`repository`*]

View File

@ -428,8 +428,12 @@ Also print diffstat from commit\.
Print only one line per commit\. Print only one line per commit\.
. .
.TP .TP
\fB\-1\fR, \fB\-\-max\-count\fR \fB\-1\fR
Print only one or a specified number of commits\. Print only one commit\.
.
.TP
\fB\-n\fR, \fB\-\-max\-count\fR
Print only a specified number of commits\.
. .
.SS "\fBmigrate\fR [\fIoptions\fR] \fIformula\fR" .SS "\fBmigrate\fR [\fIoptions\fR] \fIformula\fR"
Migrate renamed packages to new names, where \fIformula\fR are old names of packages\. Migrate renamed packages to new names, where \fIformula\fR are old names of packages\.
@ -682,6 +686,10 @@ Use \fBgit merge\fR to apply updates (rather than \fBgit rebase\fR)\.
\fB\-\-preinstall\fR \fB\-\-preinstall\fR
Run on auto\-updates (e\.g\. before \fBbrew install\fR)\. Skips some slower steps\. Run on auto\-updates (e\.g\. before \fBbrew install\fR)\. Skips some slower steps\.
. .
.TP
\fB\-f\fR, \fB\-\-force\fR
Always do a slower, full update check (even if unnecessary)\.
.
.SS "\fBupdate\-reset\fR [\fIrepository\fR]" .SS "\fBupdate\-reset\fR [\fIrepository\fR]"
Fetch and reset Homebrew and all tap repositories (or any specified \fIrepository\fR) using \fBgit\fR(1) to their latest \fBorigin/master\fR\. Fetch and reset Homebrew and all tap repositories (or any specified \fIrepository\fR) using \fBgit\fR(1) to their latest \fBorigin/master\fR\.
. .