args: Migrate usage of args loading methods to args.named
This commit is contained in:
parent
129fd33a62
commit
fa7bd3bff6
@ -220,7 +220,7 @@ begin
|
|||||||
|
|
||||||
trap("INT", old_trap)
|
trap("INT", old_trap)
|
||||||
|
|
||||||
formula = args.formulae.first
|
formula = args.named.to_formulae.first
|
||||||
options = Options.create(args.flags_only)
|
options = Options.create(args.flags_only)
|
||||||
build = Build.new(formula, options, args: args)
|
build = Build.new(formula, options, args: args)
|
||||||
build.install
|
build.install
|
||||||
|
@ -57,38 +57,47 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def formulae
|
def formulae
|
||||||
|
odeprecated "args.formulae", "args.named.formulae"
|
||||||
named.to_formulae
|
named.to_formulae
|
||||||
end
|
end
|
||||||
|
|
||||||
def formulae_and_casks
|
def formulae_and_casks
|
||||||
|
odeprecated "args.formulae_and_casks", "args.named.to_formulae_and_casks"
|
||||||
named.to_formulae_and_casks
|
named.to_formulae_and_casks
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolved_formulae
|
def resolved_formulae
|
||||||
|
odeprecated "args.resolved_formulae", "args.named.to_resolved_formulae"
|
||||||
named.to_resolved_formulae
|
named.to_resolved_formulae
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolved_formulae_casks
|
def resolved_formulae_casks
|
||||||
|
odeprecated "args.resolved_formulae_casks", "args.named.to_resolved_formulae_to_casks"
|
||||||
named.to_resolved_formulae_to_casks
|
named.to_resolved_formulae_to_casks
|
||||||
end
|
end
|
||||||
|
|
||||||
def formulae_paths
|
def formulae_paths
|
||||||
|
odeprecated "args.formulae_paths", "args.named.to_formulae_paths"
|
||||||
named.to_formulae_paths
|
named.to_formulae_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
def casks
|
def casks
|
||||||
|
odeprecated "args.casks", "args.named.homebrew_tap_cask_names"
|
||||||
named.homebrew_tap_cask_names
|
named.homebrew_tap_cask_names
|
||||||
end
|
end
|
||||||
|
|
||||||
def loaded_casks
|
def loaded_casks
|
||||||
|
odeprecated "args.loaded_casks", "args.named.to_cask"
|
||||||
named.to_casks
|
named.to_casks
|
||||||
end
|
end
|
||||||
|
|
||||||
def kegs
|
def kegs
|
||||||
|
odeprecated "args.kegs", "args.named.to_kegs"
|
||||||
named.to_kegs
|
named.to_kegs
|
||||||
end
|
end
|
||||||
|
|
||||||
def kegs_casks
|
def kegs_casks
|
||||||
|
odeprecated "args.kegs", "args.named.to_kegs_to_casks"
|
||||||
named.to_kegs_to_casks
|
named.to_kegs_to_casks
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
formulae_or_casks = if args.formula?
|
formulae_or_casks = if args.formula?
|
||||||
args.formulae
|
args.named.to_formulae
|
||||||
elsif args.cask?
|
elsif args.cask?
|
||||||
args.loaded_casks
|
args.named.to_casks
|
||||||
else
|
else
|
||||||
args.formulae_and_casks
|
args.named.to_formulae_and_casks
|
||||||
end
|
end
|
||||||
|
|
||||||
formulae_or_casks.each do |formula_or_cask|
|
formulae_or_casks.each do |formula_or_cask|
|
||||||
|
@ -19,10 +19,10 @@ module Homebrew
|
|||||||
def __caskroom
|
def __caskroom
|
||||||
args = __caskroom_args.parse
|
args = __caskroom_args.parse
|
||||||
|
|
||||||
if args.loaded_casks.blank?
|
if args.named.to_casks.blank?
|
||||||
puts Cask::Caskroom.path
|
puts Cask::Caskroom.path
|
||||||
else
|
else
|
||||||
args.loaded_casks.each do |cask|
|
args.named.to_casks.each do |cask|
|
||||||
puts "#{Cask::Caskroom.path}/#{cask.token}"
|
puts "#{Cask::Caskroom.path}/#{cask.token}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ module Homebrew
|
|||||||
if args.no_named?
|
if args.no_named?
|
||||||
puts HOMEBREW_CELLAR
|
puts HOMEBREW_CELLAR
|
||||||
else
|
else
|
||||||
puts args.resolved_formulae.map(&:rack)
|
puts args.named.to_resolved_formulae.map(&:rack)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,7 +30,7 @@ module Homebrew
|
|||||||
args = __env_args.parse
|
args = __env_args.parse
|
||||||
|
|
||||||
ENV.activate_extensions!(env: args.env)
|
ENV.activate_extensions!(env: args.env)
|
||||||
ENV.deps = args.formulae if superenv?(args.env)
|
ENV.deps = args.named.to_formulae if superenv?(args.env)
|
||||||
ENV.setup_build_environment
|
ENV.setup_build_environment
|
||||||
|
|
||||||
shell = if args.plain?
|
shell = if args.plain?
|
||||||
|
@ -25,7 +25,7 @@ module Homebrew
|
|||||||
if args.no_named?
|
if args.no_named?
|
||||||
puts HOMEBREW_PREFIX
|
puts HOMEBREW_PREFIX
|
||||||
else
|
else
|
||||||
puts args.resolved_formulae.map { |f|
|
puts args.named.to_resolved_formulae.map { |f|
|
||||||
f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix
|
f.opt_prefix.exist? ? f.opt_prefix : f.installed_prefix
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -65,7 +65,7 @@ module Homebrew
|
|||||||
Formulary.enable_factory_cache!
|
Formulary.enable_factory_cache!
|
||||||
|
|
||||||
recursive = !args.send("1?")
|
recursive = !args.send("1?")
|
||||||
installed = args.installed? || dependents(args.formulae_and_casks).all?(&:any_version_installed?)
|
installed = args.installed? || dependents(args.named.to_formulae_and_casks).all?(&:any_version_installed?)
|
||||||
|
|
||||||
@use_runtime_dependencies = installed && recursive &&
|
@use_runtime_dependencies = installed && recursive &&
|
||||||
!args.tree? &&
|
!args.tree? &&
|
||||||
@ -76,7 +76,7 @@ module Homebrew
|
|||||||
|
|
||||||
if args.tree?
|
if args.tree?
|
||||||
dependents = if args.named.present?
|
dependents = if args.named.present?
|
||||||
sorted_dependents(args.formulae_and_casks)
|
sorted_dependents(args.named.to_formulae_and_casks)
|
||||||
elsif args.installed?
|
elsif args.installed?
|
||||||
sorted_dependents(Formula.installed + Cask::Caskroom.casks)
|
sorted_dependents(Formula.installed + Cask::Caskroom.casks)
|
||||||
else
|
else
|
||||||
@ -89,7 +89,7 @@ module Homebrew
|
|||||||
puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive: recursive, args: args
|
puts_deps sorted_dependents(Formula.to_a + Cask::Cask.to_a), recursive: 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: recursive, args: args
|
puts_deps sorted_dependents(args.named.to_formulae_and_casks), recursive: recursive, args: args
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ module Homebrew
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
dependents = dependents(args.formulae_and_casks)
|
dependents = dependents(args.named.to_formulae_and_casks)
|
||||||
|
|
||||||
all_deps = deps_for_dependents(dependents, recursive: recursive, args: args, &(args.union? ? :| : :&))
|
all_deps = deps_for_dependents(dependents, recursive: recursive, args: args, &(args.union? ? :| : :&))
|
||||||
condense_requirements(all_deps, args: args)
|
condense_requirements(all_deps, args: args)
|
||||||
|
@ -47,7 +47,7 @@ module Homebrew
|
|||||||
|
|
||||||
results = if search_type.nil?
|
results = if search_type.nil?
|
||||||
desc = {}
|
desc = {}
|
||||||
args.formulae.each { |f| desc[f.full_name] = f.desc }
|
args.named.to_formulae.each { |f| desc[f.full_name] = f.desc }
|
||||||
Descriptions.new(desc)
|
Descriptions.new(desc)
|
||||||
else
|
else
|
||||||
query = args.named.join(" ")
|
query = args.named.join(" ")
|
||||||
|
@ -50,13 +50,13 @@ module Homebrew
|
|||||||
|
|
||||||
if args.deps?
|
if args.deps?
|
||||||
bucket = []
|
bucket = []
|
||||||
args.formulae.each do |f|
|
args.named.to_formulae.each do |f|
|
||||||
bucket << f
|
bucket << f
|
||||||
bucket.concat f.recursive_dependencies.map(&:to_formula)
|
bucket.concat f.recursive_dependencies.map(&:to_formula)
|
||||||
end
|
end
|
||||||
bucket.uniq!
|
bucket.uniq!
|
||||||
else
|
else
|
||||||
bucket = args.formulae
|
bucket = args.named.to_formulae
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Fetching: #{bucket * ", "}" if bucket.size > 1
|
puts "Fetching: #{bucket * ", "}" if bucket.size > 1
|
||||||
|
@ -141,6 +141,6 @@ module Homebrew
|
|||||||
|
|
||||||
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, args: args)
|
gistify_logs(args.named.to_resolved_formulae.first, args: args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,7 +24,7 @@ module Homebrew
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
homepages = args.formulae_and_casks.map do |formula_or_cask|
|
homepages = args.named.to_formulae_and_casks.map do |formula_or_cask|
|
||||||
puts "Opening homepage for #{name_of(formula_or_cask)}"
|
puts "Opening homepage for #{name_of(formula_or_cask)}"
|
||||||
formula_or_cask.homepage
|
formula_or_cask.homepage
|
||||||
end
|
end
|
||||||
|
@ -88,7 +88,7 @@ module Homebrew
|
|||||||
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.named.to_formulae.map { |f| github_info(f) })
|
||||||
else
|
else
|
||||||
print_info(args: args)
|
print_info(args: args)
|
||||||
end
|
end
|
||||||
@ -133,7 +133,7 @@ module Homebrew
|
|||||||
elsif args.installed?
|
elsif args.installed?
|
||||||
Formula.installed.sort
|
Formula.installed.sort
|
||||||
else
|
else
|
||||||
args.formulae
|
args.named.to_formulae
|
||||||
end
|
end
|
||||||
json = ff.map(&:to_hash)
|
json = ff.map(&:to_hash)
|
||||||
puts JSON.generate(json)
|
puts JSON.generate(json)
|
||||||
|
@ -115,13 +115,13 @@ module Homebrew
|
|||||||
|
|
||||||
formulae = []
|
formulae = []
|
||||||
|
|
||||||
unless args.casks.empty?
|
unless args.named.homebrew_tap_cask_names.empty?
|
||||||
cask_args = []
|
cask_args = []
|
||||||
cask_args << "--force" if args.force?
|
cask_args << "--force" if args.force?
|
||||||
cask_args << "--debug" if args.debug?
|
cask_args << "--debug" if args.debug?
|
||||||
cask_args << "--verbose" if args.verbose?
|
cask_args << "--verbose" if args.verbose?
|
||||||
|
|
||||||
args.casks.each do |c|
|
args.named.homebrew_tap_cask_names.each do |c|
|
||||||
ohai "brew cask install #{c} #{cask_args.join " "}"
|
ohai "brew cask install #{c} #{cask_args.join " "}"
|
||||||
system("#{HOMEBREW_PREFIX}/bin/brew", "cask", "install", c, *cask_args)
|
system("#{HOMEBREW_PREFIX}/bin/brew", "cask", "install", c, *cask_args)
|
||||||
end
|
end
|
||||||
@ -131,7 +131,7 @@ module Homebrew
|
|||||||
# developer tools are available, we need to stop them early on
|
# developer tools are available, we need to stop them early on
|
||||||
FormulaInstaller.prevent_build_flags(args)
|
FormulaInstaller.prevent_build_flags(args)
|
||||||
|
|
||||||
args.formulae.each do |f|
|
args.named.to_formulae.each do |f|
|
||||||
# head-only without --HEAD is an error
|
# head-only without --HEAD is an error
|
||||||
if !args.HEAD? && f.stable.nil? && f.devel.nil?
|
if !args.HEAD? && f.stable.nil? && f.devel.nil?
|
||||||
raise <<~EOS
|
raise <<~EOS
|
||||||
|
@ -37,7 +37,7 @@ module Homebrew
|
|||||||
verbose: args.verbose?,
|
verbose: args.verbose?,
|
||||||
}
|
}
|
||||||
|
|
||||||
args.kegs.each do |keg|
|
args.named.to_kegs.each do |keg|
|
||||||
keg_only = Formulary.keg_only?(keg.rack)
|
keg_only = Formulary.keg_only?(keg.rack)
|
||||||
|
|
||||||
if keg.linked?
|
if keg.linked?
|
||||||
|
@ -89,9 +89,9 @@ module Homebrew
|
|||||||
safe_system "ls", *ls_args, HOMEBREW_CELLAR
|
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.named.to_kegs.map(&:to_s) + %w[-not -type d -print], print_stdout: true
|
||||||
else
|
else
|
||||||
args.kegs.each { |keg| PrettyListing.new keg }
|
args.named.to_kegs.each { |keg| PrettyListing.new keg }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ module Homebrew
|
|||||||
|
|
||||||
def list_casks(args:)
|
def list_casks(args:)
|
||||||
Cask::Cmd::List.list_casks(
|
Cask::Cmd::List.list_casks(
|
||||||
*args.loaded_casks,
|
*args.named.to_casks,
|
||||||
one: args.public_send(:'1?'),
|
one: args.public_send(:'1?'),
|
||||||
full_name: args.full_name?,
|
full_name: args.full_name?,
|
||||||
versions: args.versions?,
|
versions: args.versions?,
|
||||||
|
@ -25,7 +25,7 @@ module Homebrew
|
|||||||
def migrate
|
def migrate
|
||||||
args = migrate_args.parse
|
args = migrate_args.parse
|
||||||
|
|
||||||
args.resolved_formulae.each do |f|
|
args.named.to_resolved_formulae.each do |f|
|
||||||
if f.oldname
|
if f.oldname
|
||||||
unless (rack = HOMEBREW_CELLAR/f.oldname).exist? && !rack.subdirs.empty?
|
unless (rack = HOMEBREW_CELLAR/f.oldname).exist? && !rack.subdirs.empty?
|
||||||
raise NoSuchKegError, f.oldname
|
raise NoSuchKegError, f.oldname
|
||||||
|
@ -31,7 +31,7 @@ module Homebrew
|
|||||||
ff = if args.no_named?
|
ff = if args.no_named?
|
||||||
Formula.installed.sort
|
Formula.installed.sort
|
||||||
else
|
else
|
||||||
args.resolved_formulae.sort
|
args.named.to_resolved_formulae.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
ff.each do |f|
|
ff.each do |f|
|
||||||
|
@ -54,7 +54,7 @@ module Homebrew
|
|||||||
elsif args.no_named?
|
elsif args.no_named?
|
||||||
raise FormulaUnspecifiedError
|
raise FormulaUnspecifiedError
|
||||||
else
|
else
|
||||||
puts_options args.formulae, args: args
|
puts_options args.named.to_formulae, args: args
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def outdated_formulae(args:)
|
def outdated_formulae(args:)
|
||||||
select_outdated((args.resolved_formulae.presence || Formula.installed), args: args).sort
|
select_outdated((args.named.to_resolved_formulae.presence || Formula.installed), args: args).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
def outdated_casks(args:)
|
def outdated_casks(args:)
|
||||||
@ -182,7 +182,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def outdated_formulae_casks(args:)
|
def outdated_formulae_casks(args:)
|
||||||
formulae, casks = args.resolved_formulae_casks
|
formulae, casks = args.named.to_resolved_formulae_to_casks
|
||||||
|
|
||||||
if formulae.blank? && casks.blank?
|
if formulae.blank? && casks.blank?
|
||||||
formulae = Formula.installed
|
formulae = Formula.installed
|
||||||
|
@ -22,7 +22,7 @@ module Homebrew
|
|||||||
def pin
|
def pin
|
||||||
args = pin_args.parse
|
args = pin_args.parse
|
||||||
|
|
||||||
args.resolved_formulae.each do |f|
|
args.named.to_resolved_formulae.each do |f|
|
||||||
if f.pinned?
|
if f.pinned?
|
||||||
opoo "#{f.name} already pinned"
|
opoo "#{f.name} already pinned"
|
||||||
elsif !f.pinnable?
|
elsif !f.pinnable?
|
||||||
|
@ -22,7 +22,7 @@ module Homebrew
|
|||||||
def postinstall
|
def postinstall
|
||||||
args = postinstall_args.parse
|
args = postinstall_args.parse
|
||||||
|
|
||||||
args.resolved_formulae.each do |f|
|
args.named.to_resolved_formulae.each do |f|
|
||||||
ohai "Postinstalling #{f}"
|
ohai "Postinstalling #{f}"
|
||||||
fi = FormulaInstaller.new(f, debug: args.debug?, quiet: args.quiet?, verbose: args.verbose?)
|
fi = FormulaInstaller.new(f, debug: args.debug?, quiet: args.quiet?, verbose: args.verbose?)
|
||||||
fi.post_install
|
fi.post_install
|
||||||
|
@ -61,7 +61,7 @@ module Homebrew
|
|||||||
|
|
||||||
Install.perform_preinstall_checks
|
Install.perform_preinstall_checks
|
||||||
|
|
||||||
resolved_formulae, casks = args.resolved_formulae_casks
|
resolved_formulae, casks = args.named.to_resolved_formulae_to_casks
|
||||||
resolved_formulae.each do |f|
|
resolved_formulae.each do |f|
|
||||||
if f.pinned?
|
if f.pinned?
|
||||||
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
onoe "#{f.full_name} is pinned. You must unpin it to reinstall."
|
||||||
|
@ -49,7 +49,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
all_kegs, casks = args.kegs_casks
|
all_kegs, casks = args.named.to_kegs_to_casks
|
||||||
kegs_by_rack = all_kegs.group_by(&:rack)
|
kegs_by_rack = all_kegs.group_by(&:rack)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ module Homebrew
|
|||||||
|
|
||||||
options = { dry_run: args.dry_run?, verbose: args.verbose? }
|
options = { dry_run: args.dry_run?, verbose: args.verbose? }
|
||||||
|
|
||||||
args.kegs.each do |keg|
|
args.named.to_kegs.each do |keg|
|
||||||
if args.dry_run?
|
if args.dry_run?
|
||||||
puts "Would remove:"
|
puts "Would remove:"
|
||||||
keg.unlink(**options)
|
keg.unlink(**options)
|
||||||
|
@ -22,7 +22,7 @@ module Homebrew
|
|||||||
def unpin
|
def unpin
|
||||||
args = unpin_args.parse
|
args = unpin_args.parse
|
||||||
|
|
||||||
args.resolved_formulae.each do |f|
|
args.named.to_resolved_formulae.each do |f|
|
||||||
if f.pinned?
|
if f.pinned?
|
||||||
f.unpin
|
f.unpin
|
||||||
elsif !f.pinnable?
|
elsif !f.pinnable?
|
||||||
|
@ -73,7 +73,7 @@ module Homebrew
|
|||||||
def upgrade
|
def upgrade
|
||||||
args = upgrade_args.parse
|
args = upgrade_args.parse
|
||||||
|
|
||||||
formulae, casks = args.resolved_formulae_casks
|
formulae, casks = args.named.to_resolved_formulae_to_casks
|
||||||
# If one or more formulae are specified, but no casks were
|
# If one or more formulae are specified, but no casks were
|
||||||
# specified, we want to make note of that so we don't
|
# specified, we want to make note of that so we don't
|
||||||
# try to upgrade all outdated casks.
|
# try to upgrade all outdated casks.
|
||||||
|
@ -56,7 +56,7 @@ module Homebrew
|
|||||||
|
|
||||||
used_formulae_missing = false
|
used_formulae_missing = false
|
||||||
used_formulae = begin
|
used_formulae = begin
|
||||||
args.formulae
|
args.named.to_formulae
|
||||||
rescue FormulaUnavailableError => e
|
rescue FormulaUnavailableError => e
|
||||||
opoo e
|
opoo e
|
||||||
used_formulae_missing = true
|
used_formulae_missing = true
|
||||||
|
@ -98,9 +98,9 @@ module Homebrew
|
|||||||
elsif args.no_named?
|
elsif args.no_named?
|
||||||
Formula
|
Formula
|
||||||
else
|
else
|
||||||
args.resolved_formulae
|
args.named.to_resolved_formulae
|
||||||
end
|
end
|
||||||
style_files = args.formulae_paths unless skip_style
|
style_files = args.named.to_formulae_paths unless skip_style
|
||||||
|
|
||||||
only_cops = args.only_cops
|
only_cops = args.only_cops
|
||||||
except_cops = args.except_cops
|
except_cops = args.except_cops
|
||||||
|
@ -88,7 +88,7 @@ module Homebrew
|
|||||||
return merge(args: args) 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.named.to_resolved_formulae.each do |f|
|
||||||
bottle_formula f, args: args
|
bottle_formula f, args: args
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -123,7 +123,7 @@ module Homebrew
|
|||||||
# Use the user's browser, too.
|
# Use the user's browser, too.
|
||||||
ENV["BROWSER"] = Homebrew::EnvConfig.browser
|
ENV["BROWSER"] = Homebrew::EnvConfig.browser
|
||||||
|
|
||||||
formula = args.formulae.first
|
formula = args.named.to_formulae.first
|
||||||
|
|
||||||
new_url = args.url
|
new_url = args.url
|
||||||
formula ||= determine_formula_from_url(new_url) if new_url
|
formula ||= determine_formula_from_url(new_url) if new_url
|
||||||
|
@ -30,7 +30,7 @@ module Homebrew
|
|||||||
# user path, too.
|
# user path, too.
|
||||||
ENV["PATH"] = ENV["HOMEBREW_PATH"]
|
ENV["PATH"] = ENV["HOMEBREW_PATH"]
|
||||||
|
|
||||||
args.formulae.each do |formula|
|
args.named.to_formulae.each do |formula|
|
||||||
current_revision = formula.revision
|
current_revision = formula.revision
|
||||||
|
|
||||||
if current_revision.zero?
|
if current_revision.zero?
|
||||||
|
@ -23,7 +23,7 @@ module Homebrew
|
|||||||
def bump
|
def bump
|
||||||
args = bump_args.parse
|
args = bump_args.parse
|
||||||
|
|
||||||
requested_formulae = args.formulae.map(&:name) if args.formulae.present?
|
requested_formulae = args.named.to_formulae.map(&:name) if args.named.to_formulae.present?
|
||||||
|
|
||||||
requested_limit = args.limit.to_i if args.limit.present?
|
requested_limit = args.limit.to_i if args.limit.present?
|
||||||
|
|
||||||
|
@ -26,6 +26,6 @@ module Homebrew
|
|||||||
else
|
else
|
||||||
"cat"
|
"cat"
|
||||||
end
|
end
|
||||||
safe_system pager, args.formulae_paths.first
|
safe_system pager, args.named.to_formulae_paths.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -28,7 +28,7 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
paths = args.formulae_paths.presence
|
paths = args.named.to_formulae_paths.presence
|
||||||
|
|
||||||
# If no brews are listed, open the project root in an editor.
|
# If no brews are listed, open the project root in an editor.
|
||||||
paths ||= [HOMEBREW_REPOSITORY]
|
paths ||= [HOMEBREW_REPOSITORY]
|
||||||
|
@ -21,6 +21,6 @@ module Homebrew
|
|||||||
def formula
|
def formula
|
||||||
args = formula_args.parse
|
args = formula_args.parse
|
||||||
|
|
||||||
args.formulae_paths.each(&method(:puts))
|
args.named.to_formulae_paths.each(&method(:puts))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -31,10 +31,10 @@ module Homebrew
|
|||||||
args = 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.named.to_kegs.empty?
|
||||||
Formula.installed.map(&:opt_or_installed_prefix_keg).reject(&:nil?)
|
Formula.installed.map(&:opt_or_installed_prefix_keg).reject(&:nil?)
|
||||||
else
|
else
|
||||||
args.kegs
|
args.named.to_kegs
|
||||||
end
|
end
|
||||||
kegs.each do |keg|
|
kegs.each do |keg|
|
||||||
ohai "Checking #{keg.name} linkage" if kegs.size > 1
|
ohai "Checking #{keg.name} linkage" if kegs.size > 1
|
||||||
|
@ -33,7 +33,7 @@ module Homebrew
|
|||||||
|
|
||||||
bintray = Bintray.new(org: bintray_org)
|
bintray = Bintray.new(org: bintray_org)
|
||||||
|
|
||||||
args.formulae.each do |formula|
|
args.named.to_formulae.each do |formula|
|
||||||
mirror_url = bintray.mirror_formula(formula, repo: bintray_repo, publish_package: !args.no_publish?)
|
mirror_url = bintray.mirror_formula(formula, repo: bintray_repo, publish_package: !args.no_publish?)
|
||||||
ohai "Mirrored #{formula.full_name} to #{mirror_url}!"
|
ohai "Mirrored #{formula.full_name} to #{mirror_url}!"
|
||||||
end
|
end
|
||||||
|
@ -44,7 +44,7 @@ module Homebrew
|
|||||||
elsif args.named.any? { |tap| tap.count("/") == 1 }
|
elsif args.named.any? { |tap| tap.count("/") == 1 }
|
||||||
args.named.map { |tap| Tap.fetch(tap).path }
|
args.named.map { |tap| Tap.fetch(tap).path }
|
||||||
else
|
else
|
||||||
args.formulae_paths
|
args.named.to_formulae_paths
|
||||||
end
|
end
|
||||||
|
|
||||||
only_cops = args.only_cops
|
only_cops = args.only_cops
|
||||||
|
@ -39,7 +39,7 @@ module Homebrew
|
|||||||
require "formula_assertions"
|
require "formula_assertions"
|
||||||
require "formula_free_port"
|
require "formula_free_port"
|
||||||
|
|
||||||
args.resolved_formulae.each do |f|
|
args.named.to_resolved_formulae.each do |f|
|
||||||
# Cannot test uninstalled formulae
|
# Cannot test uninstalled formulae
|
||||||
unless f.latest_version_installed?
|
unless f.latest_version_installed?
|
||||||
ofail "Testing requires the latest version of #{f.full_name}"
|
ofail "Testing requires the latest version of #{f.full_name}"
|
||||||
|
@ -33,7 +33,7 @@ module Homebrew
|
|||||||
def unpack
|
def unpack
|
||||||
args = unpack_args.parse
|
args = unpack_args.parse
|
||||||
|
|
||||||
formulae = args.formulae
|
formulae = args.named.to_formulae
|
||||||
|
|
||||||
if dir = args.destdir
|
if dir = args.destdir
|
||||||
unpack_dir = Pathname.new(dir).expand_path
|
unpack_dir = Pathname.new(dir).expand_path
|
||||||
|
@ -29,7 +29,7 @@ module Homebrew
|
|||||||
def update_python_resources
|
def update_python_resources
|
||||||
args = update_python_resources_args.parse
|
args = update_python_resources_args.parse
|
||||||
|
|
||||||
args.formulae.each do |formula|
|
args.named.to_formulae.each do |formula|
|
||||||
PyPI.update_python_resources! formula, args.version, print_only: args.print_only?, silent: args.silent?,
|
PyPI.update_python_resources! formula, args.version, print_only: args.print_only?, silent: args.silent?,
|
||||||
ignore_non_pypi_packages: args.ignore_non_pypi_packages?
|
ignore_non_pypi_packages: args.ignore_non_pypi_packages?
|
||||||
end
|
end
|
||||||
|
@ -112,7 +112,7 @@ class FormulaInstaller
|
|||||||
|
|
||||||
return if build_flags.empty?
|
return if build_flags.empty?
|
||||||
|
|
||||||
all_bottled = args.formulae.all?(&:bottled?)
|
all_bottled = args.named.to_formulae.all?(&:bottled?)
|
||||||
raise BuildFlagsError.new(build_flags, bottled: all_bottled)
|
raise BuildFlagsError.new(build_flags, bottled: all_bottled)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ begin
|
|||||||
|
|
||||||
trap("INT", old_trap)
|
trap("INT", old_trap)
|
||||||
|
|
||||||
formula = args.resolved_formulae.first
|
formula = args.named.to_resolved_formulae.first
|
||||||
formula.extend(Debrew::Formula) if args.debug?
|
formula.extend(Debrew::Formula) if args.debug?
|
||||||
formula.run_post_install
|
formula.run_post_install
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
|
@ -24,7 +24,7 @@ begin
|
|||||||
|
|
||||||
trap("INT", old_trap)
|
trap("INT", old_trap)
|
||||||
|
|
||||||
formula = args.resolved_formulae.first
|
formula = args.named.to_resolved_formulae.first
|
||||||
formula.extend(Homebrew::Assertions)
|
formula.extend(Homebrew::Assertions)
|
||||||
formula.extend(Homebrew::FreePort)
|
formula.extend(Homebrew::FreePort)
|
||||||
formula.extend(Debrew::Formula) if args.debug?
|
formula.extend(Debrew::Formula) if args.debug?
|
||||||
|
@ -10,12 +10,6 @@ describe Homebrew::CLI::NamedArgs do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:foo_keg) do
|
|
||||||
path = (HOMEBREW_CELLAR/"foo/1.0").resolved_path
|
|
||||||
mkdir_p path
|
|
||||||
Keg.new(path)
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:bar) do
|
let(:bar) do
|
||||||
formula "bar" do
|
formula "bar" do
|
||||||
url "https://brew.sh"
|
url "https://brew.sh"
|
||||||
@ -23,12 +17,6 @@ describe Homebrew::CLI::NamedArgs do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:bar_keg) do
|
|
||||||
path = (HOMEBREW_CELLAR/"bar/1.0").resolved_path
|
|
||||||
mkdir_p path
|
|
||||||
Keg.new(path)
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:baz) do
|
let(:baz) do
|
||||||
Cask::CaskLoader.load(+<<~RUBY)
|
Cask::CaskLoader.load(+<<~RUBY)
|
||||||
cask "baz" do
|
cask "baz" do
|
||||||
@ -44,6 +32,14 @@ describe Homebrew::CLI::NamedArgs do
|
|||||||
|
|
||||||
expect(described_class.new("foo", "bar").to_formulae).to eq [foo, bar]
|
expect(described_class.new("foo", "bar").to_formulae).to eq [foo, bar]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "raises an error when a Formula is unavailable" do
|
||||||
|
expect { described_class.new("mxcl").to_formulae }.to raise_error FormulaUnavailableError
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns an empty array when there are no Formulae" do
|
||||||
|
expect(described_class.new.to_formulae).to be_empty
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#to_formulae_and_casks" do
|
describe "#to_formulae_and_casks" do
|
||||||
@ -85,26 +81,43 @@ describe Homebrew::CLI::NamedArgs do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "#to_kegs" do
|
describe "#to_kegs" do
|
||||||
it "returns kegs" do
|
before do
|
||||||
named_args = described_class.new("foo", "bar")
|
(HOMEBREW_CELLAR/"foo/1.0").mkpath
|
||||||
allow(named_args).to receive(:resolve_keg).with("foo").and_return foo_keg
|
(HOMEBREW_CELLAR/"bar/1.0").mkpath
|
||||||
allow(named_args).to receive(:resolve_keg).with("bar").and_return bar_keg
|
end
|
||||||
|
|
||||||
expect(named_args.to_kegs).to eq [foo_keg, bar_keg]
|
it "resolves kegs with #resolve_kegs" do
|
||||||
|
expect(described_class.new("foo", "bar").to_kegs.map(&:name)).to eq ["foo", "bar"]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "when there are no matching kegs returns an array of Kegs" do
|
||||||
|
expect(described_class.new.to_kegs).to be_empty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#to_kegs_to_casks" do
|
describe "#to_kegs_to_casks" do
|
||||||
|
before do
|
||||||
|
(HOMEBREW_CELLAR/"foo/1.0").mkpath
|
||||||
|
end
|
||||||
|
|
||||||
it "returns kegs, as well as casks" do
|
it "returns kegs, as well as casks" do
|
||||||
named_args = described_class.new("foo", "baz")
|
|
||||||
allow(named_args).to receive(:resolve_keg).and_call_original
|
|
||||||
allow(named_args).to receive(:resolve_keg).with("foo").and_return foo_keg
|
|
||||||
stub_cask_loader baz, call_original: true
|
stub_cask_loader baz, call_original: true
|
||||||
|
|
||||||
kegs, casks = named_args.to_kegs_to_casks
|
kegs, casks = described_class.new("foo", "baz").to_kegs_to_casks
|
||||||
|
|
||||||
expect(kegs).to eq [foo_keg]
|
expect(kegs.map(&:name)).to eq ["foo"]
|
||||||
expect(casks).to eq [baz]
|
expect(casks).to eq [baz]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#homebrew_tap_cask_names" do
|
||||||
|
it "returns an array of casks from homebrew-cask" do
|
||||||
|
expect(described_class.new("foo", "homebrew/cask/local-caffeine").homebrew_tap_cask_names)
|
||||||
|
.to eq ["homebrew/cask/local-caffeine"]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns an empty array when there are no matching casks" do
|
||||||
|
expect(described_class.new("foo").homebrew_tap_cask_names).to be_empty
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -270,38 +270,6 @@ describe Homebrew::CLI::Parser do
|
|||||||
expect(args.flags_only).to eq %w[--verbose --foo --bar=value]
|
expect(args.flags_only).to eq %w[--verbose --foo --bar=value]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "#formulae raises an error when a Formula is unavailable" do
|
|
||||||
args = parser.parse(["mxcl"])
|
|
||||||
expect { args.formulae }.to raise_error FormulaUnavailableError
|
|
||||||
end
|
|
||||||
|
|
||||||
it "#formulae returns an empty array when there are no Formulae" do
|
|
||||||
args = parser.parse([])
|
|
||||||
expect(args.formulae).to be_empty
|
|
||||||
end
|
|
||||||
|
|
||||||
it "#casks returns an empty array when there are no matching casks" do
|
|
||||||
args = parser.parse([])
|
|
||||||
expect(args.casks).to eq []
|
|
||||||
end
|
|
||||||
|
|
||||||
context "kegs" do
|
|
||||||
before do
|
|
||||||
keg = HOMEBREW_CELLAR/"mxcl/10.0"
|
|
||||||
keg.mkpath
|
|
||||||
end
|
|
||||||
|
|
||||||
it "when there are matching kegs returns an array of Kegs" do
|
|
||||||
args = parser.parse(["mxcl"])
|
|
||||||
expect(args.kegs.length).to eq 1
|
|
||||||
end
|
|
||||||
|
|
||||||
it "when there are no matching kegs returns an array of Kegs" do
|
|
||||||
args = parser.parse([])
|
|
||||||
expect(args.kegs).to be_empty
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it "#named returns an array of non-option arguments" do
|
it "#named returns an array of non-option arguments" do
|
||||||
args = parser.parse(["foo", "-v", "-s"])
|
args = parser.parse(["foo", "-v", "-s"])
|
||||||
expect(args.named).to eq ["foo"]
|
expect(args.named).to eq ["foo"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user