Merge pull request #6840 from GauthamGoli/argv-cleanup-6
ARGV: Replace usages of ARGV.named with Homebrew.args.named
This commit is contained in:
commit
2749c52d3f
@ -59,6 +59,8 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def named
|
def named
|
||||||
|
return [] if remaining.nil?
|
||||||
|
|
||||||
remaining
|
remaining
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Homebrew
|
|||||||
def __cellar
|
def __cellar
|
||||||
__cellar_args.parse
|
__cellar_args.parse
|
||||||
|
|
||||||
if ARGV.named.empty?
|
if Homebrew.args.named.blank?
|
||||||
puts HOMEBREW_CELLAR
|
puts HOMEBREW_CELLAR
|
||||||
else
|
else
|
||||||
puts ARGV.resolved_formulae.map(&:rack)
|
puts ARGV.resolved_formulae.map(&:rack)
|
||||||
|
@ -22,7 +22,7 @@ module Homebrew
|
|||||||
def __prefix
|
def __prefix
|
||||||
__prefix_args.parse
|
__prefix_args.parse
|
||||||
|
|
||||||
if ARGV.named.empty?
|
if Homebrew.args.named.blank?
|
||||||
puts HOMEBREW_PREFIX
|
puts HOMEBREW_PREFIX
|
||||||
else
|
else
|
||||||
puts ARGV.resolved_formulae.map { |f|
|
puts ARGV.resolved_formulae.map { |f|
|
||||||
|
@ -67,7 +67,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
if args.category.present?
|
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"
|
raise UsageError, "--category must be one of #{VALID_FORMULA_CATEGORIES.join(", ")} when querying formulae"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -78,13 +78,13 @@ module Homebrew
|
|||||||
|
|
||||||
if args.json
|
if args.json
|
||||||
raise UsageError, "Invalid JSON version: #{args.json}" unless ["v1", true].include? 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"
|
raise UsageError, "This command's option requires a formula argument"
|
||||||
end
|
end
|
||||||
|
|
||||||
print_json
|
print_json
|
||||||
elsif args.github?
|
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) })
|
exec_browser(*Homebrew.args.formulae.map { |f| github_info(f) })
|
||||||
else
|
else
|
||||||
@ -93,7 +93,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def print_info
|
def print_info
|
||||||
if ARGV.named.empty?
|
if Homebrew.args.named.blank?
|
||||||
if args.analytics?
|
if args.analytics?
|
||||||
Utils::Analytics.output
|
Utils::Analytics.output
|
||||||
elsif HOMEBREW_CELLAR.exist?
|
elsif HOMEBREW_CELLAR.exist?
|
||||||
@ -101,7 +101,7 @@ module Homebrew
|
|||||||
puts "#{count} #{"keg".pluralize(count)}, #{HOMEBREW_CELLAR.dup.abv}"
|
puts "#{count} #{"keg".pluralize(count)}, #{HOMEBREW_CELLAR.dup.abv}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ARGV.named.each_with_index do |f, i|
|
Homebrew.args.named.each_with_index do |f, i|
|
||||||
puts unless i.zero?
|
puts unless i.zero?
|
||||||
begin
|
begin
|
||||||
formula = if f.include?("/") || File.exist?(f)
|
formula = if f.include?("/") || File.exist?(f)
|
||||||
|
@ -92,7 +92,9 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def install
|
def install
|
||||||
ARGV.named.each do |name|
|
install_args.parse
|
||||||
|
|
||||||
|
Homebrew.args.named.each do |name|
|
||||||
next if File.exist?(name)
|
next if File.exist?(name)
|
||||||
next if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX
|
next if name !~ HOMEBREW_TAP_FORMULA_REGEX && name !~ HOMEBREW_CASK_TAP_CASK_REGEX
|
||||||
|
|
||||||
@ -100,8 +102,6 @@ module Homebrew
|
|||||||
tap.install unless tap.installed?
|
tap.install unless tap.installed?
|
||||||
end
|
end
|
||||||
|
|
||||||
install_args.parse
|
|
||||||
|
|
||||||
raise FormulaUnspecifiedError if args.remaining.empty?
|
raise FormulaUnspecifiedError if args.remaining.empty?
|
||||||
|
|
||||||
if args.ignore_dependencies?
|
if args.ignore_dependencies?
|
||||||
|
@ -55,14 +55,14 @@ module Homebrew
|
|||||||
# Unbrewed uses the PREFIX, which will exist
|
# Unbrewed uses the PREFIX, which will exist
|
||||||
# Things below use the CELLAR, which doesn't until the first formula is installed.
|
# Things below use the CELLAR, which doesn't until the first formula is installed.
|
||||||
unless HOMEBREW_CELLAR.exist?
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if args.pinned? || args.versions?
|
if args.pinned? || args.versions?
|
||||||
filtered_list
|
filtered_list
|
||||||
elsif ARGV.named.empty?
|
elsif Homebrew.args.named.blank?
|
||||||
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)
|
||||||
return if full_names.empty?
|
return if full_names.empty?
|
||||||
@ -123,10 +123,10 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def filtered_list
|
def filtered_list
|
||||||
names = if ARGV.named.empty?
|
names = if Homebrew.args.named.blank?
|
||||||
Formula.racks
|
Formula.racks
|
||||||
else
|
else
|
||||||
racks = ARGV.named.map { |n| Formulary.to_rack(n) }
|
racks = Homebrew.args.named.map { |n| Formulary.to_rack(n) }
|
||||||
racks.select do |rack|
|
racks.select do |rack|
|
||||||
Homebrew.failed = true unless rack.exist?
|
Homebrew.failed = true unless rack.exist?
|
||||||
rack.exist?
|
rack.exist?
|
||||||
|
@ -25,7 +25,7 @@ module Homebrew
|
|||||||
def migrate
|
def migrate
|
||||||
migrate_args.parse
|
migrate_args.parse
|
||||||
|
|
||||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
raise FormulaUnspecifiedError if Homebrew.args.named.blank?
|
||||||
|
|
||||||
ARGV.resolved_formulae.each do |f|
|
ARGV.resolved_formulae.each do |f|
|
||||||
if f.oldname
|
if f.oldname
|
||||||
|
@ -30,7 +30,7 @@ module Homebrew
|
|||||||
|
|
||||||
return unless HOMEBREW_CELLAR.exist?
|
return unless HOMEBREW_CELLAR.exist?
|
||||||
|
|
||||||
ff = if ARGV.named.empty?
|
ff = if Homebrew.args.named.blank?
|
||||||
Formula.installed.sort
|
Formula.installed.sort
|
||||||
else
|
else
|
||||||
ARGV.resolved_formulae.sort
|
ARGV.resolved_formulae.sort
|
||||||
|
@ -38,12 +38,12 @@ module Homebrew
|
|||||||
def style
|
def style
|
||||||
style_args.parse
|
style_args.parse
|
||||||
|
|
||||||
target = if ARGV.named.empty?
|
target = if Homebrew.args.named.blank?
|
||||||
nil
|
nil
|
||||||
elsif ARGV.named.any? { |file| File.exist? file }
|
elsif Homebrew.args.named.any? { |file| File.exist? file }
|
||||||
ARGV.named
|
Homebrew.args.named
|
||||||
elsif ARGV.named.any? { |tap| tap.count("/") == 1 }
|
elsif Homebrew.args.named.any? { |tap| tap.count("/") == 1 }
|
||||||
ARGV.named.map { |tap| Tap.fetch(tap).path }
|
Homebrew.args.named.map { |tap| Tap.fetch(tap).path }
|
||||||
else
|
else
|
||||||
Homebrew.args.formulae.map(&:path)
|
Homebrew.args.formulae.map(&:path)
|
||||||
end
|
end
|
||||||
|
@ -30,7 +30,7 @@ module Homebrew
|
|||||||
if args.installed?
|
if args.installed?
|
||||||
taps = Tap
|
taps = Tap
|
||||||
else
|
else
|
||||||
taps = ARGV.named.sort.map do |name|
|
taps = Homebrew.args.named.sort.map do |name|
|
||||||
Tap.fetch(name)
|
Tap.fetch(name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -61,7 +61,7 @@ module Homebrew
|
|||||||
|
|
||||||
Install.perform_preinstall_checks
|
Install.perform_preinstall_checks
|
||||||
|
|
||||||
if ARGV.named.empty?
|
if Homebrew.args.named.blank?
|
||||||
outdated = Formula.installed.select do |f|
|
outdated = Formula.installed.select do |f|
|
||||||
f.outdated?(fetch_head: args.fetch_HEAD?)
|
f.outdated?(fetch_head: args.fetch_HEAD?)
|
||||||
end
|
end
|
||||||
@ -170,7 +170,7 @@ module Homebrew
|
|||||||
fi = FormulaInstaller.new(f)
|
fi = FormulaInstaller.new(f)
|
||||||
fi.options = options
|
fi.options = options
|
||||||
fi.build_bottle = args.build_bottle?
|
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
|
fi.link_keg ||= keg_was_linked if keg_had_linked_opt
|
||||||
if tab
|
if tab
|
||||||
fi.build_bottle ||= tab.built_bottle?
|
fi.build_bottle ||= tab.built_bottle?
|
||||||
|
@ -55,7 +55,7 @@ module Homebrew
|
|||||||
opoo e
|
opoo e
|
||||||
used_formulae_missing = true
|
used_formulae_missing = true
|
||||||
# If the formula doesn't exist: fake the needed formula object name.
|
# 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
|
end
|
||||||
|
|
||||||
use_runtime_dependents = args.installed? &&
|
use_runtime_dependents = args.installed? &&
|
||||||
|
@ -79,7 +79,7 @@ module Homebrew
|
|||||||
ENV.activate_extensions!
|
ENV.activate_extensions!
|
||||||
ENV.setup_build_environment
|
ENV.setup_build_environment
|
||||||
|
|
||||||
if ARGV.named.empty?
|
if Homebrew.args.named.blank?
|
||||||
ff = Formula
|
ff = Formula
|
||||||
files = Tap.map(&:formula_dir)
|
files = Tap.map(&:formula_dir)
|
||||||
else
|
else
|
||||||
|
@ -427,9 +427,9 @@ module Homebrew
|
|||||||
|
|
||||||
def merge
|
def merge
|
||||||
write = args.write?
|
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)))
|
hash.deep_merge(JSON.parse(IO.read(json_file)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ module Homebrew
|
|||||||
def formula
|
def formula
|
||||||
formula_args.parse
|
formula_args.parse
|
||||||
|
|
||||||
raise FormulaUnspecifiedError if ARGV.named.empty?
|
raise FormulaUnspecifiedError if Homebrew.args.named.blank?
|
||||||
|
|
||||||
ARGV.resolved_formulae.each { |f| puts f.path }
|
ARGV.resolved_formulae.each { |f| puts f.path }
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user