Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARGV: Replace usages of ARGV.named with Homebrew.args.named #6840

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Library/Homebrew/cli/args.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def passthrough
end

def named
return [] if remaining.nil?

remaining
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/--cellar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __cellar_args
def __cellar
__cellar_args.parse

if ARGV.named.empty?
if Homebrew.args.named.blank?
puts HOMEBREW_CELLAR
else
puts ARGV.resolved_formulae.map(&:rack)
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/--prefix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __prefix_args
def __prefix
__prefix_args.parse

if ARGV.named.empty?
if Homebrew.args.named.blank?
puts HOMEBREW_PREFIX
else
puts ARGV.resolved_formulae.map { |f|
Expand Down
10 changes: 5 additions & 5 deletions Library/Homebrew/cmd/info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def info
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

Expand All @@ -78,13 +78,13 @@ def info

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
Expand All @@ -93,15 +93,15 @@ def info
end

def print_info
if ARGV.named.empty?
if Homebrew.args.named.blank?
if args.analytics?
Utils::Analytics.output
elsif HOMEBREW_CELLAR.exist?
count = Formula.racks.length
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)
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/cmd/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ def install_args
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

tap = Tap.fetch(Regexp.last_match(1), Regexp.last_match(2))
tap.install unless tap.installed?
end

install_args.parse

raise FormulaUnspecifiedError if args.remaining.empty?

if args.ignore_dependencies?
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/cmd/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ def list
# 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?
Expand Down Expand Up @@ -123,10 +123,10 @@ def list_unbrewed
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?
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/migrate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def migrate_args
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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/missing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def missing

return unless HOMEBREW_CELLAR.exist?

ff = if ARGV.named.empty?
ff = if Homebrew.args.named.blank?
Formula.installed.sort
else
ARGV.resolved_formulae.sort
Expand Down
10 changes: 5 additions & 5 deletions Library/Homebrew/cmd/style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def style_args
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
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/tap-info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def tap_info
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
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/cmd/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def upgrade

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
Expand Down Expand Up @@ -170,7 +170,7 @@ def upgrade_formula(f)
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?
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cmd/uses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def uses
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? &&
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def audit
ENV.activate_extensions!
ENV.setup_build_environment

if ARGV.named.empty?
if Homebrew.args.named.blank?
ff = Formula
files = Tap.map(&:formula_dir)
else
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/dev-cmd/bottle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,9 @@ def bottle_formula(f)

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

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def formula_args
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
Expand Down