Merge pull request #6840 from GauthamGoli/argv-cleanup-6

ARGV: Replace usages of ARGV.named with Homebrew.args.named
This commit is contained in:
Gautham Goli 2019-12-19 00:48:27 +05:30 committed by GitHub
commit 2749c52d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 31 additions and 29 deletions

View File

@ -59,6 +59,8 @@ module Homebrew
end
def named
return [] if remaining.nil?
remaining
end

View File

@ -22,7 +22,7 @@ module Homebrew
def __cellar
__cellar_args.parse
if ARGV.named.empty?
if Homebrew.args.named.blank?
puts HOMEBREW_CELLAR
else
puts ARGV.resolved_formulae.map(&:rack)

View File

@ -22,7 +22,7 @@ module Homebrew
def __prefix
__prefix_args.parse
if ARGV.named.empty?
if Homebrew.args.named.blank?
puts HOMEBREW_PREFIX
else
puts ARGV.resolved_formulae.map { |f|

View File

@ -67,7 +67,7 @@ module Homebrew
end
if args.category.present?
if ARGV.named.present? && !VALID_FORMULA_CATEGORIES.include?(args.category)
if Homebrew.args.named.present? && !VALID_FORMULA_CATEGORIES.include?(args.category)
raise UsageError, "--category must be one of #{VALID_FORMULA_CATEGORIES.join(", ")} when querying formulae"
end
@ -78,13 +78,13 @@ module Homebrew
if args.json
raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? args.json
if !(args.all? || args.installed?) && ARGV.named.blank?
if !(args.all? || args.installed?) && Homebrew.args.named.blank?
raise UsageError, "This command's option requires a formula argument"
end
print_json
elsif args.github?
raise UsageError, "This command's option requires a formula argument" if ARGV.named.empty?
raise UsageError, "This command's option requires a formula argument" if Homebrew.args.named.blank?
exec_browser(*Homebrew.args.formulae.map { |f| github_info(f) })
else
@ -93,7 +93,7 @@ module Homebrew
end
def print_info
if ARGV.named.empty?
if Homebrew.args.named.blank?
if args.analytics?
Utils::Analytics.output
elsif HOMEBREW_CELLAR.exist?
@ -101,7 +101,7 @@ module Homebrew
puts "#{count} #{"keg".pluralize(count)}, #{HOMEBREW_CELLAR.dup.abv}"
end
else
ARGV.named.each_with_index do |f, i|
Homebrew.args.named.each_with_index do |f, i|
puts unless i.zero?
begin
formula = if f.include?("/") || File.exist?(f)

View File

@ -92,7 +92,9 @@ module Homebrew
end
def install
ARGV.named.each do |name|
install_args.parse
Homebrew.args.named.each do |name|
next if File.exist?(name)
next if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX
@ -100,8 +102,6 @@ module Homebrew
tap.install unless tap.installed?
end
install_args.parse
raise FormulaUnspecifiedError if args.remaining.empty?
if args.ignore_dependencies?

View File

@ -55,14 +55,14 @@ module Homebrew
# Unbrewed uses the PREFIX, which will exist
# Things below use the CELLAR, which doesn't until the first formula is installed.
unless HOMEBREW_CELLAR.exist?
raise NoSuchKegError, ARGV.named.first unless ARGV.named.empty?
raise NoSuchKegError, Hombrew.args.named.first if Homebrew.args.named.present?
return
end
if args.pinned? || args.versions?
filtered_list
elsif ARGV.named.empty?
elsif Homebrew.args.named.blank?
if args.full_name?
full_names = Formula.installed.map(&:full_name).sort(&tap_and_name_comparison)
return if full_names.empty?
@ -123,10 +123,10 @@ module Homebrew
end
def filtered_list
names = if ARGV.named.empty?
names = if Homebrew.args.named.blank?
Formula.racks
else
racks = ARGV.named.map { |n| Formulary.to_rack(n) }
racks = Homebrew.args.named.map { |n| Formulary.to_rack(n) }
racks.select do |rack|
Homebrew.failed = true unless rack.exist?
rack.exist?

View File

@ -25,7 +25,7 @@ module Homebrew
def migrate
migrate_args.parse
raise FormulaUnspecifiedError if ARGV.named.empty?
raise FormulaUnspecifiedError if Homebrew.args.named.blank?
ARGV.resolved_formulae.each do |f|
if f.oldname

View File

@ -30,7 +30,7 @@ module Homebrew
return unless HOMEBREW_CELLAR.exist?
ff = if ARGV.named.empty?
ff = if Homebrew.args.named.blank?
Formula.installed.sort
else
ARGV.resolved_formulae.sort

View File

@ -38,12 +38,12 @@ module Homebrew
def style
style_args.parse
target = if ARGV.named.empty?
target = if Homebrew.args.named.blank?
nil
elsif ARGV.named.any? { |file| File.exist? file }
ARGV.named
elsif ARGV.named.any? { |tap| tap.count("/") == 1 }
ARGV.named.map { |tap| Tap.fetch(tap).path }
elsif Homebrew.args.named.any? { |file| File.exist? file }
Homebrew.args.named
elsif Homebrew.args.named.any? { |tap| tap.count("/") == 1 }
Homebrew.args.named.map { |tap| Tap.fetch(tap).path }
else
Homebrew.args.formulae.map(&:path)
end

View File

@ -30,7 +30,7 @@ module Homebrew
if args.installed?
taps = Tap
else
taps = ARGV.named.sort.map do |name|
taps = Homebrew.args.named.sort.map do |name|
Tap.fetch(name)
end
end

View File

@ -61,7 +61,7 @@ module Homebrew
Install.perform_preinstall_checks
if ARGV.named.empty?
if Homebrew.args.named.blank?
outdated = Formula.installed.select do |f|
f.outdated?(fetch_head: args.fetch_HEAD?)
end
@ -170,7 +170,7 @@ module Homebrew
fi = FormulaInstaller.new(f)
fi.options = options
fi.build_bottle = args.build_bottle?
fi.installed_on_request = !ARGV.named.empty?
fi.installed_on_request = Homebrew.args.named.present?
fi.link_keg ||= keg_was_linked if keg_had_linked_opt
if tab
fi.build_bottle ||= tab.built_bottle?

View File

@ -55,7 +55,7 @@ module Homebrew
opoo e
used_formulae_missing = true
# If the formula doesn't exist: fake the needed formula object name.
ARGV.named.map { |name| OpenStruct.new name: name, full_name: name }
Homebrew.args.named.map { |name| OpenStruct.new name: name, full_name: name }
end
use_runtime_dependents = args.installed? &&

View File

@ -79,7 +79,7 @@ module Homebrew
ENV.activate_extensions!
ENV.setup_build_environment
if ARGV.named.empty?
if Homebrew.args.named.blank?
ff = Formula
files = Tap.map(&:formula_dir)
else

View File

@ -427,9 +427,9 @@ module Homebrew
def merge
write = args.write?
raise UsageError, "--merge requires a JSON file path argument" if ARGV.named.empty?
raise UsageError, "--merge requires a JSON file path argument" if Homebrew.args.named.blank?
bottles_hash = ARGV.named.reduce({}) do |hash, json_file|
bottles_hash = Homebrew.args.named.reduce({}) do |hash, json_file|
hash.deep_merge(JSON.parse(IO.read(json_file)))
end

View File

@ -21,7 +21,7 @@ module Homebrew
def formula
formula_args.parse
raise FormulaUnspecifiedError if ARGV.named.empty?
raise FormulaUnspecifiedError if Homebrew.args.named.blank?
ARGV.resolved_formulae.each { |f| puts f.path }
end