mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
cli_parser: Store parsed args in Homebrew.args and access args everywhere else
This commit is contained in:
parent
05ff35b4ab
commit
fba52e2f74
@ -11,9 +11,9 @@ module Homebrew
|
|||||||
|
|
||||||
def initialize(&block)
|
def initialize(&block)
|
||||||
@parser = OptionParser.new
|
@parser = OptionParser.new
|
||||||
@parsed_args = OpenStruct.new
|
Homebrew.args = OpenStruct.new
|
||||||
# undefine tap to allow --tap argument
|
# undefine tap to allow --tap argument
|
||||||
@parsed_args.instance_eval { undef tap }
|
Homebrew.args.instance_eval { undef tap }
|
||||||
@constraints = []
|
@constraints = []
|
||||||
@conflicts = []
|
@conflicts = []
|
||||||
instance_eval(&block)
|
instance_eval(&block)
|
||||||
@ -24,20 +24,20 @@ module Homebrew
|
|||||||
global_switch = names.first.is_a?(Symbol)
|
global_switch = names.first.is_a?(Symbol)
|
||||||
names, env = common_switch(*names) if global_switch
|
names, env = common_switch(*names) if global_switch
|
||||||
@parser.on(*names, description) do
|
@parser.on(*names, description) do
|
||||||
enable_switch(*names, global_switch)
|
enable_switch(*names)
|
||||||
end
|
end
|
||||||
enable_switch(*names, global_switch) if !env.nil? &&
|
|
||||||
!ENV["HOMEBREW_#{env.to_s.upcase}"].nil?
|
|
||||||
|
|
||||||
names.each do |name|
|
names.each do |name|
|
||||||
set_constraints(name, required_for: required_for, depends_on: depends_on)
|
set_constraints(name, required_for: required_for, depends_on: depends_on)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
enable_switch(*names) if !env.nil? && !ENV["HOMEBREW_#{env.to_s.upcase}"].nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def comma_array(name, description: nil)
|
def comma_array(name, description: nil)
|
||||||
description = option_to_description(name) if description.nil?
|
description = option_to_description(name) if description.nil?
|
||||||
@parser.on(name, OptionParser::REQUIRED_ARGUMENT, Array, description) do |list|
|
@parser.on(name, OptionParser::REQUIRED_ARGUMENT, Array, description) do |list|
|
||||||
@parsed_args[option_to_name(name)] = list
|
Homebrew.args[option_to_name(name)] = list
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
description = option_to_description(name) if description.nil?
|
description = option_to_description(name) if description.nil?
|
||||||
@parser.on(name, description, required) do |option_value|
|
@parser.on(name, description, required) do |option_value|
|
||||||
@parsed_args[option_to_name(name)] = option_value
|
Homebrew.args[option_to_name(name)] = option_value
|
||||||
end
|
end
|
||||||
|
|
||||||
set_constraints(name, required_for: required_for, depends_on: depends_on)
|
set_constraints(name, required_for: required_for, depends_on: depends_on)
|
||||||
@ -71,18 +71,13 @@ module Homebrew
|
|||||||
def parse(cmdline_args = ARGV)
|
def parse(cmdline_args = ARGV)
|
||||||
@parser.parse(cmdline_args)
|
@parser.parse(cmdline_args)
|
||||||
check_constraint_violations
|
check_constraint_violations
|
||||||
@parsed_args
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def enable_switch(*names, global_switch)
|
def enable_switch(*names)
|
||||||
names.each do |name|
|
names.each do |name|
|
||||||
if global_switch
|
Homebrew.args["#{option_to_name(name)}?"] = true
|
||||||
Homebrew.args["#{option_to_name(name)}?"] = true
|
|
||||||
next
|
|
||||||
end
|
|
||||||
@parsed_args["#{option_to_name(name)}?"] = true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -98,7 +93,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def option_passed?(name)
|
def option_passed?(name)
|
||||||
@parsed_args.respond_to?(name) || @parsed_args.respond_to?("#{name}?")
|
Homebrew.args.respond_to?(name) || Homebrew.args.respond_to?("#{name}?")
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_constraints(name, depends_on:, required_for:)
|
def set_constraints(name, depends_on:, required_for:)
|
||||||
|
@ -26,7 +26,7 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def list
|
def list
|
||||||
@args = CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--unbrewed"
|
switch "--unbrewed"
|
||||||
switch "--pinned"
|
switch "--pinned"
|
||||||
switch "--versions"
|
switch "--versions"
|
||||||
@ -41,7 +41,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Use of exec means we don't explicitly exit
|
# Use of exec means we don't explicitly exit
|
||||||
list_unbrewed if @args.unbrewed?
|
list_unbrewed if args.unbrewed?
|
||||||
|
|
||||||
# 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.
|
||||||
@ -50,10 +50,10 @@ module Homebrew
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if @args.pinned? || @args.versions?
|
if args.pinned? || args.versions?
|
||||||
filtered_list
|
filtered_list
|
||||||
elsif ARGV.named.empty?
|
elsif ARGV.named.empty?
|
||||||
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?
|
||||||
puts Formatter.columns(full_names)
|
puts Formatter.columns(full_names)
|
||||||
@ -61,7 +61,7 @@ module Homebrew
|
|||||||
ENV["CLICOLOR"] = nil
|
ENV["CLICOLOR"] = nil
|
||||||
exec "ls", *ARGV.options_only << HOMEBREW_CELLAR
|
exec "ls", *ARGV.options_only << HOMEBREW_CELLAR
|
||||||
end
|
end
|
||||||
elsif Homebrew.args.verbose? || !$stdout.tty?
|
elsif args.verbose? || !$stdout.tty?
|
||||||
exec "find", *ARGV.kegs.map(&:to_s) + %w[-not -type d -print]
|
exec "find", *ARGV.kegs.map(&:to_s) + %w[-not -type d -print]
|
||||||
else
|
else
|
||||||
ARGV.kegs.each { |keg| PrettyListing.new keg }
|
ARGV.kegs.each { |keg| PrettyListing.new keg }
|
||||||
@ -121,7 +121,7 @@ module Homebrew
|
|||||||
rack.exist?
|
rack.exist?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @args.pinned?
|
if args.pinned?
|
||||||
pinned_versions = {}
|
pinned_versions = {}
|
||||||
names.sort.each do |d|
|
names.sort.each do |d|
|
||||||
keg_pin = (HOMEBREW_PINNED_KEGS/d.basename.to_s)
|
keg_pin = (HOMEBREW_PINNED_KEGS/d.basename.to_s)
|
||||||
@ -130,12 +130,12 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
pinned_versions.each do |d, version|
|
pinned_versions.each do |d, version|
|
||||||
puts d.basename.to_s.concat(@args.versions? ? " #{version}" : "")
|
puts d.basename.to_s.concat(args.versions? ? " #{version}" : "")
|
||||||
end
|
end
|
||||||
else # --versions without --pinned
|
else # --versions without --pinned
|
||||||
names.sort.each do |d|
|
names.sort.each do |d|
|
||||||
versions = d.subdirs.map { |pn| pn.basename.to_s }
|
versions = d.subdirs.map { |pn| pn.basename.to_s }
|
||||||
next if @args.multiple? && versions.length < 2
|
next if args.multiple? && versions.length < 2
|
||||||
puts "#{d.basename} #{versions * " "}"
|
puts "#{d.basename} #{versions * " "}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -53,7 +53,7 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def audit
|
def audit
|
||||||
args = Homebrew::CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--strict"
|
switch "--strict"
|
||||||
switch "--online"
|
switch "--online"
|
||||||
switch "--new-formula"
|
switch "--new-formula"
|
||||||
|
@ -71,7 +71,7 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def bottle
|
def bottle
|
||||||
@args = Homebrew::CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--merge"
|
switch "--merge"
|
||||||
switch "--skip-relocation"
|
switch "--skip-relocation"
|
||||||
switch "--force-core-tap"
|
switch "--force-core-tap"
|
||||||
@ -86,7 +86,7 @@ module Homebrew
|
|||||||
flag "--root-url"
|
flag "--root-url"
|
||||||
end
|
end
|
||||||
|
|
||||||
return merge if @args.merge?
|
return merge if args.merge?
|
||||||
ARGV.resolved_formulae.each do |f|
|
ARGV.resolved_formulae.each do |f|
|
||||||
bottle_formula f
|
bottle_formula f
|
||||||
end
|
end
|
||||||
@ -117,7 +117,7 @@ module Homebrew
|
|||||||
linked_libraries = Keg.file_linked_libraries(file, string)
|
linked_libraries = Keg.file_linked_libraries(file, string)
|
||||||
result ||= !linked_libraries.empty?
|
result ||= !linked_libraries.empty?
|
||||||
|
|
||||||
if Homebrew.args.verbose?
|
if args.verbose?
|
||||||
print_filename.call(string, file) unless linked_libraries.empty?
|
print_filename.call(string, file) unless linked_libraries.empty?
|
||||||
linked_libraries.each do |lib|
|
linked_libraries.each do |lib|
|
||||||
puts " #{Tty.bold}-->#{Tty.reset} links to #{lib}"
|
puts " #{Tty.bold}-->#{Tty.reset} links to #{lib}"
|
||||||
@ -140,7 +140,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
next unless Homebrew.args.verbose? && !text_matches.empty?
|
next unless args.verbose? && !text_matches.empty?
|
||||||
print_filename.call(string, file)
|
print_filename.call(string, file)
|
||||||
text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset|
|
text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset|
|
||||||
puts " #{Tty.bold}-->#{Tty.reset} match '#{match}' at offset #{Tty.bold}0x#{offset}#{Tty.reset}"
|
puts " #{Tty.bold}-->#{Tty.reset} match '#{match}' at offset #{Tty.bold}0x#{offset}#{Tty.reset}"
|
||||||
@ -161,7 +161,7 @@ module Homebrew
|
|||||||
absolute_symlinks_start_with_string << pn if link.to_s.start_with?(string)
|
absolute_symlinks_start_with_string << pn if link.to_s.start_with?(string)
|
||||||
end
|
end
|
||||||
|
|
||||||
if Homebrew.args.verbose?
|
if args.verbose?
|
||||||
unless absolute_symlinks_start_with_string.empty?
|
unless absolute_symlinks_start_with_string.empty?
|
||||||
opoo "Absolute symlink starting with #{string}:"
|
opoo "Absolute symlink starting with #{string}:"
|
||||||
absolute_symlinks_start_with_string.each do |pn|
|
absolute_symlinks_start_with_string.each do |pn|
|
||||||
@ -184,7 +184,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
unless tap = f.tap
|
unless tap = f.tap
|
||||||
unless @args.force_core_tap?
|
unless args.force_core_tap?
|
||||||
return ofail "Formula not from core or any taps: #{f.full_name}"
|
return ofail "Formula not from core or any taps: #{f.full_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -203,9 +203,9 @@ module Homebrew
|
|||||||
|
|
||||||
return ofail "Formula has no stable version: #{f.full_name}" unless f.stable
|
return ofail "Formula has no stable version: #{f.full_name}" unless f.stable
|
||||||
|
|
||||||
if @args.no_rebuild? || !f.tap
|
if args.no_rebuild? || !f.tap
|
||||||
rebuild = 0
|
rebuild = 0
|
||||||
elsif @args.keep_old?
|
elsif args.keep_old?
|
||||||
rebuild = f.bottle_specification.rebuild
|
rebuild = f.bottle_specification.rebuild
|
||||||
else
|
else
|
||||||
ohai "Determining #{f.full_name} bottle rebuild..."
|
ohai "Determining #{f.full_name} bottle rebuild..."
|
||||||
@ -238,7 +238,7 @@ module Homebrew
|
|||||||
begin
|
begin
|
||||||
keg.delete_pyc_files!
|
keg.delete_pyc_files!
|
||||||
|
|
||||||
unless @args.skip_relocation?
|
unless args.skip_relocation?
|
||||||
changed_files = keg.replace_locations_with_placeholders
|
changed_files = keg.replace_locations_with_placeholders
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
relocatable = true
|
relocatable = true
|
||||||
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)
|
relocatable = false if keg_contain?(prefix_check, keg, ignores)
|
||||||
@ -302,21 +302,21 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
skip_relocation = relocatable && !keg.require_relocation?
|
skip_relocation = relocatable && !keg.require_relocation?
|
||||||
end
|
end
|
||||||
puts if !relocatable && Homebrew.args.verbose?
|
puts if !relocatable && args.verbose?
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
ignore_interrupts { bottle_path.unlink if bottle_path.exist? }
|
ignore_interrupts { bottle_path.unlink if bottle_path.exist? }
|
||||||
raise
|
raise
|
||||||
ensure
|
ensure
|
||||||
ignore_interrupts do
|
ignore_interrupts do
|
||||||
original_tab&.write
|
original_tab&.write
|
||||||
unless @args.skip_relocation?
|
unless args.skip_relocation?
|
||||||
keg.replace_placeholders_with_locations changed_files
|
keg.replace_placeholders_with_locations changed_files
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
root_url = @args.root_url
|
root_url = args.root_url
|
||||||
|
|
||||||
bottle = BottleSpecification.new
|
bottle = BottleSpecification.new
|
||||||
bottle.tap = tap
|
bottle.tap = tap
|
||||||
@ -336,7 +336,7 @@ module Homebrew
|
|||||||
bottle.sha256 sha256 => Utils::Bottles.tag
|
bottle.sha256 sha256 => Utils::Bottles.tag
|
||||||
|
|
||||||
old_spec = f.bottle_specification
|
old_spec = f.bottle_specification
|
||||||
if @args.keep_old? && !old_spec.checksums.empty?
|
if args.keep_old? && !old_spec.checksums.empty?
|
||||||
mismatches = [:root_url, :prefix, :cellar, :rebuild].reject do |key|
|
mismatches = [:root_url, :prefix, :cellar, :rebuild].reject do |key|
|
||||||
old_spec.send(key) == bottle.send(key)
|
old_spec.send(key) == bottle.send(key)
|
||||||
end
|
end
|
||||||
@ -362,9 +362,9 @@ module Homebrew
|
|||||||
puts "./#{filename}"
|
puts "./#{filename}"
|
||||||
puts output
|
puts output
|
||||||
|
|
||||||
return unless @args.json?
|
return unless args.json?
|
||||||
tag = Utils::Bottles.tag.to_s
|
tag = Utils::Bottles.tag.to_s
|
||||||
tag += "_or_later" if @args.or_later?
|
tag += "_or_later" if args.or_later?
|
||||||
json = {
|
json = {
|
||||||
f.full_name => {
|
f.full_name => {
|
||||||
"formula" => {
|
"formula" => {
|
||||||
@ -395,7 +395,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def merge
|
def merge
|
||||||
write = @args.write?
|
write = args.write?
|
||||||
|
|
||||||
bottles_hash = ARGV.named.reduce({}) do |hash, json_file|
|
bottles_hash = ARGV.named.reduce({}) do |hash, json_file|
|
||||||
deep_merge_hashes hash, JSON.parse(IO.read(json_file))
|
deep_merge_hashes hash, JSON.parse(IO.read(json_file))
|
||||||
@ -424,7 +424,7 @@ module Homebrew
|
|||||||
Utils::Inreplace.inreplace(path) do |s|
|
Utils::Inreplace.inreplace(path) do |s|
|
||||||
if s.include? "bottle do"
|
if s.include? "bottle do"
|
||||||
update_or_add = "update"
|
update_or_add = "update"
|
||||||
if @args.keep_old?
|
if args.keep_old?
|
||||||
mismatches = []
|
mismatches = []
|
||||||
bottle_block_contents = s[/ bottle do(.+?)end\n/m, 1]
|
bottle_block_contents = s[/ bottle do(.+?)end\n/m, 1]
|
||||||
bottle_block_contents.lines.each do |line|
|
bottle_block_contents.lines.each do |line|
|
||||||
@ -467,7 +467,7 @@ module Homebrew
|
|||||||
string = s.sub!(/ bottle do.+?end\n/m, output)
|
string = s.sub!(/ bottle do.+?end\n/m, output)
|
||||||
odie "Bottle block update failed!" unless string
|
odie "Bottle block update failed!" unless string
|
||||||
else
|
else
|
||||||
if @args.keep_old?
|
if args.keep_old?
|
||||||
odie "--keep-old was passed but there was no existing bottle block!"
|
odie "--keep-old was passed but there was no existing bottle block!"
|
||||||
end
|
end
|
||||||
puts output
|
puts output
|
||||||
@ -496,7 +496,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless @args.no_commit?
|
unless args.no_commit?
|
||||||
if ENV["HOMEBREW_GIT_NAME"]
|
if ENV["HOMEBREW_GIT_NAME"]
|
||||||
ENV["GIT_AUTHOR_NAME"] =
|
ENV["GIT_AUTHOR_NAME"] =
|
||||||
ENV["GIT_COMMITTER_NAME"] =
|
ENV["GIT_COMMITTER_NAME"] =
|
||||||
|
@ -48,7 +48,7 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def bump_formula_pr
|
def bump_formula_pr
|
||||||
@bump_args = Homebrew::CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--devel"
|
switch "--devel"
|
||||||
switch "-n", "--dry-run"
|
switch "-n", "--dry-run"
|
||||||
switch "--write"
|
switch "--write"
|
||||||
@ -93,7 +93,7 @@ module Homebrew
|
|||||||
checked_for_duplicates = true
|
checked_for_duplicates = true
|
||||||
end
|
end
|
||||||
|
|
||||||
new_url = @bump_args.url
|
new_url = args.url
|
||||||
if new_url && !formula
|
if new_url && !formula
|
||||||
# Split the new URL on / and find any formulae that have the same URL
|
# Split the new URL on / and find any formulae that have the same URL
|
||||||
# except for the last component, but don't try to match any more than the
|
# except for the last component, but don't try to match any more than the
|
||||||
@ -104,7 +104,7 @@ module Homebrew
|
|||||||
components_to_match = [new_url_split.count - 1, maximum_url_components_to_match].min
|
components_to_match = [new_url_split.count - 1, maximum_url_components_to_match].min
|
||||||
base_url = new_url_split.first(components_to_match).join("/")
|
base_url = new_url_split.first(components_to_match).join("/")
|
||||||
base_url = /#{Regexp.escape(base_url)}/
|
base_url = /#{Regexp.escape(base_url)}/
|
||||||
is_devel = @bump_args.devel?
|
is_devel = args.devel?
|
||||||
guesses = []
|
guesses = []
|
||||||
Formula.each do |f|
|
Formula.each do |f|
|
||||||
if is_devel && f.devel && f.devel.url && f.devel.url.match(base_url)
|
if is_devel && f.devel && f.devel.url && f.devel.url.match(base_url)
|
||||||
@ -123,7 +123,7 @@ module Homebrew
|
|||||||
|
|
||||||
check_for_duplicate_pull_requests(formula) unless checked_for_duplicates
|
check_for_duplicate_pull_requests(formula) unless checked_for_duplicates
|
||||||
|
|
||||||
requested_spec, formula_spec = if @bump_args.devel?
|
requested_spec, formula_spec = if args.devel?
|
||||||
devel_message = " (devel)"
|
devel_message = " (devel)"
|
||||||
[:devel, formula.devel]
|
[:devel, formula.devel]
|
||||||
else
|
else
|
||||||
@ -135,11 +135,11 @@ module Homebrew
|
|||||||
[checksum.hash_type, checksum.hexdigest]
|
[checksum.hash_type, checksum.hexdigest]
|
||||||
end
|
end
|
||||||
|
|
||||||
new_hash = @bump_args[hash_type] if hash_type
|
new_hash = args[hash_type] if hash_type
|
||||||
new_tag = @bump_args.tag
|
new_tag = args.tag
|
||||||
new_revision = @bump_args.revision
|
new_revision = args.revision
|
||||||
new_mirror = @bump_args.mirror
|
new_mirror = args.mirror
|
||||||
forced_version = @bump_args.version
|
forced_version = args.version
|
||||||
new_url_hash = if new_url && new_hash
|
new_url_hash = if new_url && new_hash
|
||||||
true
|
true
|
||||||
elsif new_tag && new_revision
|
elsif new_tag && new_revision
|
||||||
@ -176,7 +176,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @bump_args.dry_run?
|
if args.dry_run?
|
||||||
ohai "brew update"
|
ohai "brew update"
|
||||||
else
|
else
|
||||||
safe_system "brew", "update"
|
safe_system "brew", "update"
|
||||||
@ -205,7 +205,7 @@ module Homebrew
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
backup_file = File.read(formula.path) unless @bump_args.dry_run?
|
backup_file = File.read(formula.path) unless args.dry_run?
|
||||||
|
|
||||||
if new_mirror
|
if new_mirror
|
||||||
replacement_pairs << [/^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m, "\\1\\2\\1mirror \"#{new_mirror}\"\n"]
|
replacement_pairs << [/^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m, "\\1\\2\\1mirror \"#{new_mirror}\"\n"]
|
||||||
@ -235,31 +235,31 @@ module Homebrew
|
|||||||
new_formula_version = formula_version(formula, requested_spec, new_contents)
|
new_formula_version = formula_version(formula, requested_spec, new_contents)
|
||||||
|
|
||||||
if new_formula_version < old_formula_version
|
if new_formula_version < old_formula_version
|
||||||
formula.path.atomic_write(backup_file) unless @bump_args.dry_run?
|
formula.path.atomic_write(backup_file) unless args.dry_run?
|
||||||
odie <<~EOS
|
odie <<~EOS
|
||||||
You probably need to bump this formula manually since changing the
|
You probably need to bump this formula manually since changing the
|
||||||
version from #{old_formula_version} to #{new_formula_version} would be a downgrade.
|
version from #{old_formula_version} to #{new_formula_version} would be a downgrade.
|
||||||
EOS
|
EOS
|
||||||
elsif new_formula_version == old_formula_version
|
elsif new_formula_version == old_formula_version
|
||||||
formula.path.atomic_write(backup_file) unless @bump_args.dry_run?
|
formula.path.atomic_write(backup_file) unless args.dry_run?
|
||||||
odie <<~EOS
|
odie <<~EOS
|
||||||
You probably need to bump this formula manually since the new version
|
You probably need to bump this formula manually since the new version
|
||||||
and old version are both #{new_formula_version}.
|
and old version are both #{new_formula_version}.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
if @bump_args.dry_run?
|
if args.dry_run?
|
||||||
if @bump_args.strict?
|
if args.strict?
|
||||||
ohai "brew audit --strict #{formula.path.basename}"
|
ohai "brew audit --strict #{formula.path.basename}"
|
||||||
elsif @bump_args.audit?
|
elsif args.audit?
|
||||||
ohai "brew audit #{formula.path.basename}"
|
ohai "brew audit #{formula.path.basename}"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
failed_audit = false
|
failed_audit = false
|
||||||
if @bump_args.strict?
|
if args.strict?
|
||||||
system HOMEBREW_BREW_FILE, "audit", "--strict", formula.path
|
system HOMEBREW_BREW_FILE, "audit", "--strict", formula.path
|
||||||
failed_audit = !$CHILD_STATUS.success?
|
failed_audit = !$CHILD_STATUS.success?
|
||||||
elsif @bump_args.audit?
|
elsif args.audit?
|
||||||
system HOMEBREW_BREW_FILE, "audit", formula.path
|
system HOMEBREW_BREW_FILE, "audit", formula.path
|
||||||
failed_audit = !$CHILD_STATUS.success?
|
failed_audit = !$CHILD_STATUS.success?
|
||||||
end
|
end
|
||||||
@ -274,7 +274,7 @@ module Homebrew
|
|||||||
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")
|
||||||
|
|
||||||
if @bump_args.dry_run?
|
if args.dry_run?
|
||||||
ohai "fork repository with GitHub API"
|
ohai "fork repository with GitHub API"
|
||||||
ohai "git fetch --unshallow origin" if shallow
|
ohai "git fetch --unshallow origin" if shallow
|
||||||
ohai "git checkout --no-track -b #{branch} origin/master"
|
ohai "git checkout --no-track -b #{branch} origin/master"
|
||||||
@ -306,7 +306,7 @@ module Homebrew
|
|||||||
pr_message = <<~EOS
|
pr_message = <<~EOS
|
||||||
Created with `brew bump-formula-pr`.
|
Created with `brew bump-formula-pr`.
|
||||||
EOS
|
EOS
|
||||||
user_message = @bump_args.message
|
user_message = args.message
|
||||||
if user_message
|
if user_message
|
||||||
pr_message += "\n" + <<~EOS
|
pr_message += "\n" + <<~EOS
|
||||||
---
|
---
|
||||||
@ -319,7 +319,7 @@ module Homebrew
|
|||||||
begin
|
begin
|
||||||
url = GitHub.create_pull_request(formula.tap.full_name, pr_title,
|
url = GitHub.create_pull_request(formula.tap.full_name, pr_title,
|
||||||
"#{username}:#{branch}", "master", pr_message)["html_url"]
|
"#{username}:#{branch}", "master", pr_message)["html_url"]
|
||||||
if @bump_args.no_browse?
|
if args.no_browse?
|
||||||
puts url
|
puts url
|
||||||
else
|
else
|
||||||
exec_browser url
|
exec_browser url
|
||||||
@ -332,7 +332,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def inreplace_pairs(path, replacement_pairs)
|
def inreplace_pairs(path, replacement_pairs)
|
||||||
if @bump_args.dry_run?
|
if args.dry_run?
|
||||||
contents = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read }
|
contents = path.open("r") { |f| Formulary.ensure_utf8_encoding(f).read }
|
||||||
contents.extend(StringInreplaceExtension)
|
contents.extend(StringInreplaceExtension)
|
||||||
replacement_pairs.each do |old, new|
|
replacement_pairs.each do |old, new|
|
||||||
@ -344,7 +344,7 @@ module Homebrew
|
|||||||
unless contents.errors.empty?
|
unless contents.errors.empty?
|
||||||
raise Utils::InreplaceError, path => contents.errors
|
raise Utils::InreplaceError, path => contents.errors
|
||||||
end
|
end
|
||||||
path.atomic_write(contents) if @bump_args.write?
|
path.atomic_write(contents) if args.write?
|
||||||
contents
|
contents
|
||||||
else
|
else
|
||||||
Utils::Inreplace.inreplace(path) do |s|
|
Utils::Inreplace.inreplace(path) do |s|
|
||||||
|
@ -43,7 +43,7 @@ module Homebrew
|
|||||||
paths = ARGV.named.map do |name|
|
paths = ARGV.named.map do |name|
|
||||||
path = Formulary.path(name)
|
path = Formulary.path(name)
|
||||||
|
|
||||||
raise FormulaUnavailableError, name unless path.file? || Homebrew.args.force?
|
raise FormulaUnavailableError, name unless path.file? || args.force?
|
||||||
|
|
||||||
path
|
path
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,7 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def irb
|
def irb
|
||||||
args = Homebrew::CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--examples"
|
switch "--examples"
|
||||||
switch "--pry", env: :pry
|
switch "--pry", env: :pry
|
||||||
end
|
end
|
||||||
|
@ -20,14 +20,14 @@ module Homebrew
|
|||||||
TARGET_DOC_PATH = HOMEBREW_REPOSITORY/"docs"
|
TARGET_DOC_PATH = HOMEBREW_REPOSITORY/"docs"
|
||||||
|
|
||||||
def man
|
def man
|
||||||
@args = Homebrew::CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--fail-if-changed"
|
switch "--fail-if-changed"
|
||||||
switch "--link"
|
switch "--link"
|
||||||
end
|
end
|
||||||
|
|
||||||
raise UsageError unless ARGV.named.empty?
|
raise UsageError unless ARGV.named.empty?
|
||||||
|
|
||||||
if @args.link?
|
if args.link?
|
||||||
odie "`brew man --link` is now done automatically by `brew update`."
|
odie "`brew man --link` is now done automatically by `brew update`."
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ module Homebrew
|
|||||||
|
|
||||||
if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/Manpage.md", "manpages"
|
if system "git", "-C", HOMEBREW_REPOSITORY, "diff", "--quiet", "docs/Manpage.md", "manpages"
|
||||||
puts "No changes to manpage output detected."
|
puts "No changes to manpage output detected."
|
||||||
elsif @args.fail_if_changed?
|
elsif args.fail_if_changed?
|
||||||
Homebrew.failed = true
|
Homebrew.failed = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -94,7 +94,7 @@ module 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 args.fail_if_changed? &&
|
||||||
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)}")
|
||||||
|
@ -74,7 +74,7 @@ module Homebrew
|
|||||||
def pull
|
def pull
|
||||||
odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase"
|
odie "You meant `git pull --rebase`." if ARGV[0] == "--rebase"
|
||||||
|
|
||||||
@args = Homebrew::CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--bottle"
|
switch "--bottle"
|
||||||
switch "--bump"
|
switch "--bump"
|
||||||
switch "--clean"
|
switch "--clean"
|
||||||
@ -116,7 +116,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do_bump = @args.bump? && !@args.clean?
|
do_bump = args.bump? && !args.clean?
|
||||||
|
|
||||||
# Formulae with affected bottles that were published
|
# Formulae with affected bottles that were published
|
||||||
bintray_published_formulae = []
|
bintray_published_formulae = []
|
||||||
@ -135,7 +135,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
_, testing_job = *testing_match
|
_, testing_job = *testing_match
|
||||||
url = "https://github.com/Homebrew/homebrew-#{tap.repo}/compare/master...BrewTestBot:testing-#{testing_job}"
|
url = "https://github.com/Homebrew/homebrew-#{tap.repo}/compare/master...BrewTestBot:testing-#{testing_job}"
|
||||||
odie "Testing URLs require `--bottle`!" unless @args.bottle?
|
odie "Testing URLs require `--bottle`!" unless args.bottle?
|
||||||
elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX)
|
elsif (api_match = arg.match HOMEBREW_PULL_API_REGEX)
|
||||||
_, user, repo, issue = *api_match
|
_, user, repo, issue = *api_match
|
||||||
url = "https://github.com/#{user}/#{repo}/pull/#{issue}"
|
url = "https://github.com/#{user}/#{repo}/pull/#{issue}"
|
||||||
@ -147,7 +147,7 @@ module Homebrew
|
|||||||
odie "Not a GitHub pull request or commit: #{arg}"
|
odie "Not a GitHub pull request or commit: #{arg}"
|
||||||
end
|
end
|
||||||
|
|
||||||
if !testing_job && @args.bottle? && issue.nil?
|
if !testing_job && args.bottle? && issue.nil?
|
||||||
odie "No pull request detected!"
|
odie "No pull request detected!"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -165,11 +165,11 @@ module Homebrew
|
|||||||
orig_revision = `git rev-parse --short HEAD`.strip
|
orig_revision = `git rev-parse --short HEAD`.strip
|
||||||
branch = `git symbolic-ref --short HEAD`.strip
|
branch = `git symbolic-ref --short HEAD`.strip
|
||||||
|
|
||||||
unless branch == "master" || @args.clean? || @args.branch_okay?
|
unless branch == "master" || args.clean? || args.branch_okay?
|
||||||
opoo "Current branch is #{branch}: do you need to pull inside master?"
|
opoo "Current branch is #{branch}: do you need to pull inside master?"
|
||||||
end
|
end
|
||||||
|
|
||||||
patch_puller = PatchPuller.new(url, @args)
|
patch_puller = PatchPuller.new(url, args)
|
||||||
patch_puller.fetch_patch
|
patch_puller.fetch_patch
|
||||||
patch_changes = files_changed_in_patch(patch_puller.patchpath, tap)
|
patch_changes = files_changed_in_patch(patch_puller.patchpath, tap)
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @args.bottle?
|
if args.bottle?
|
||||||
if f.bottle_unneeded?
|
if f.bottle_unneeded?
|
||||||
ohai "#{f}: skipping unneeded bottle."
|
ohai "#{f}: skipping unneeded bottle."
|
||||||
elsif f.bottle_disabled?
|
elsif f.bottle_disabled?
|
||||||
@ -232,7 +232,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
orig_message = message = `git log HEAD^.. --format=%B`
|
orig_message = message = `git log HEAD^.. --format=%B`
|
||||||
if issue && !@args.clean?
|
if issue && !args.clean?
|
||||||
ohai "Patch closes issue ##{issue}"
|
ohai "Patch closes issue ##{issue}"
|
||||||
close_message = "Closes ##{issue}."
|
close_message = "Closes ##{issue}."
|
||||||
# If this is a pull request, append a close message.
|
# If this is a pull request, append a close message.
|
||||||
@ -244,7 +244,7 @@ module Homebrew
|
|||||||
is_bumpable = false
|
is_bumpable = false
|
||||||
end
|
end
|
||||||
|
|
||||||
is_bumpable = false if @args.clean?
|
is_bumpable = false if args.clean?
|
||||||
is_bumpable = false if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
|
is_bumpable = false if ENV["HOMEBREW_DISABLE_LOAD_FORMULA"]
|
||||||
|
|
||||||
if is_bumpable
|
if is_bumpable
|
||||||
@ -256,7 +256,7 @@ module Homebrew
|
|||||||
odie "No version changes found for #{formula.name}" if bump_subject.nil?
|
odie "No version changes found for #{formula.name}" if bump_subject.nil?
|
||||||
unless orig_subject == bump_subject
|
unless orig_subject == bump_subject
|
||||||
ohai "New bump commit subject: #{bump_subject}"
|
ohai "New bump commit subject: #{bump_subject}"
|
||||||
pbcopy bump_subject unless @args.no_pbcopy?
|
pbcopy bump_subject unless args.no_pbcopy?
|
||||||
message = "#{bump_subject}\n\n#{message}"
|
message = "#{bump_subject}\n\n#{message}"
|
||||||
end
|
end
|
||||||
elsif bump_subject != orig_subject && !bump_subject.nil?
|
elsif bump_subject != orig_subject && !bump_subject.nil?
|
||||||
@ -265,7 +265,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if message != orig_message && !@args.clean?
|
if message != orig_message && !args.clean?
|
||||||
safe_system "git", "commit", "--amend", "--signoff", "--allow-empty", "-q", "-m", message
|
safe_system "git", "commit", "--amend", "--signoff", "--allow-empty", "-q", "-m", message
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ module Homebrew
|
|||||||
url
|
url
|
||||||
else
|
else
|
||||||
bottle_branch = "pull-bottle-#{issue}"
|
bottle_branch = "pull-bottle-#{issue}"
|
||||||
bot_username = GitHub.test_bot_user(user, @args.test_bot_user)
|
bot_username = GitHub.test_bot_user(user, args.test_bot_user)
|
||||||
"https://github.com/#{bot_username}/homebrew-#{tap.repo}/compare/#{user}:master...pr-#{issue}"
|
"https://github.com/#{bot_username}/homebrew-#{tap.repo}/compare/#{user}:master...pr-#{issue}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ module Homebrew
|
|||||||
safe_system "git", "branch", "--quiet", "-D", bottle_branch
|
safe_system "git", "branch", "--quiet", "-D", bottle_branch
|
||||||
|
|
||||||
# Publish bottles on Bintray
|
# Publish bottles on Bintray
|
||||||
unless @args.no_publish?
|
unless args.no_publish?
|
||||||
published = publish_changed_formula_bottles(tap, changed_formulae_names)
|
published = publish_changed_formula_bottles(tap, changed_formulae_names)
|
||||||
bintray_published_formulae.concat(published)
|
bintray_published_formulae.concat(published)
|
||||||
end
|
end
|
||||||
@ -320,7 +320,7 @@ module Homebrew
|
|||||||
changed_formulae_names.each do |name|
|
changed_formulae_names.each do |name|
|
||||||
f = Formula[name]
|
f = Formula[name]
|
||||||
next if f.bottle_unneeded? || f.bottle_disabled?
|
next if f.bottle_unneeded? || f.bottle_disabled?
|
||||||
bintray_org = @args.bintray_org || tap.user.downcase
|
bintray_org = args.bintray_org || tap.user.downcase
|
||||||
next unless publish_bottle_file_on_bintray(f, bintray_org, bintray_creds)
|
next unless publish_bottle_file_on_bintray(f, bintray_org, bintray_creds)
|
||||||
published << f.full_name
|
published << f.full_name
|
||||||
end
|
end
|
||||||
@ -331,7 +331,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def pull_patch(url, description = nil)
|
def pull_patch(url, description = nil)
|
||||||
PatchPuller.new(url, @args, description).pull_patch
|
PatchPuller.new(url, args, description).pull_patch
|
||||||
end
|
end
|
||||||
|
|
||||||
class PatchPuller
|
class PatchPuller
|
||||||
|
@ -11,7 +11,7 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def release_notes
|
def release_notes
|
||||||
args = Homebrew::CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--markdown"
|
switch "--markdown"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def tests
|
def tests
|
||||||
args = Homebrew::CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--no-compat"
|
switch "--no-compat"
|
||||||
switch "--generic"
|
switch "--generic"
|
||||||
switch "--coverage"
|
switch "--coverage"
|
||||||
@ -98,8 +98,8 @@ module Homebrew
|
|||||||
# seeds being output when running parallel tests.
|
# seeds being output when running parallel tests.
|
||||||
seed = args.seed ? args.seed : rand(0xFFFF).to_i
|
seed = args.seed ? args.seed : rand(0xFFFF).to_i
|
||||||
|
|
||||||
args = ["-I", HOMEBREW_LIBRARY_PATH/"test"]
|
bundle_args = ["-I", HOMEBREW_LIBRARY_PATH/"test"]
|
||||||
args += %W[
|
bundle_args += %W[
|
||||||
--seed #{seed}
|
--seed #{seed}
|
||||||
--color
|
--color
|
||||||
--require spec_helper
|
--require spec_helper
|
||||||
@ -109,21 +109,21 @@ module Homebrew
|
|||||||
]
|
]
|
||||||
|
|
||||||
unless OS.mac?
|
unless OS.mac?
|
||||||
args << "--tag" << "~needs_macos"
|
bundle_args << "--tag" << "~needs_macos"
|
||||||
files = files.reject { |p| p =~ %r{^test/(os/mac|cask)(/.*|_spec\.rb)$} }
|
files = files.reject { |p| p =~ %r{^test/(os/mac|cask)(/.*|_spec\.rb)$} }
|
||||||
end
|
end
|
||||||
|
|
||||||
unless OS.linux?
|
unless OS.linux?
|
||||||
args << "--tag" << "~needs_linux"
|
bundle_args << "--tag" << "~needs_linux"
|
||||||
files = files.reject { |p| p =~ %r{^test/os/linux(/.*|_spec\.rb)$} }
|
files = files.reject { |p| p =~ %r{^test/os/linux(/.*|_spec\.rb)$} }
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Randomized with seed #{seed}"
|
puts "Randomized with seed #{seed}"
|
||||||
|
|
||||||
if parallel
|
if parallel
|
||||||
system "bundle", "exec", "parallel_rspec", *opts, "--", *args, "--", *files
|
system "bundle", "exec", "parallel_rspec", *opts, "--", *bundle_args, "--", *files
|
||||||
else
|
else
|
||||||
system "bundle", "exec", "rspec", *args, "--", *files
|
system "bundle", "exec", "rspec", *bundle_args, "--", *files
|
||||||
end
|
end
|
||||||
|
|
||||||
return if $CHILD_STATUS.success?
|
return if $CHILD_STATUS.success?
|
||||||
|
@ -20,7 +20,7 @@ module Homebrew
|
|||||||
module_function
|
module_function
|
||||||
|
|
||||||
def update_test
|
def update_test
|
||||||
args = Homebrew::CLI::Parser.parse do
|
Homebrew::CLI::Parser.parse do
|
||||||
switch "--to-tag"
|
switch "--to-tag"
|
||||||
switch "--keep-tmp"
|
switch "--keep-tmp"
|
||||||
switch :verbose
|
switch :verbose
|
||||||
|
@ -33,9 +33,9 @@ describe Homebrew::CLI::Parser do
|
|||||||
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
|
||||||
args = parser.parse(["--verbose"])
|
parser.parse(["--verbose"])
|
||||||
expect(Homebrew.args).to be_verbose
|
expect(Homebrew.args).to be_verbose
|
||||||
expect(args.more_verbose?).to be nil
|
expect(Homebrew.args.more_verbose?).to be nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an exception when an invalid option is passed" do
|
it "raises an exception when an invalid option is passed" do
|
||||||
@ -43,8 +43,8 @@ describe Homebrew::CLI::Parser do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "maps environment var to an option" do
|
it "maps environment var to an option" do
|
||||||
args = parser.parse([])
|
parser.parse([])
|
||||||
expect(args.pry?).to be true
|
expect(Homebrew.args.pry?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -57,8 +57,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
|
||||||
args = parser.parse(["--filename=random.txt"])
|
parser.parse(["--filename=random.txt"])
|
||||||
expect(args.filename).to eq "random.txt"
|
expect(Homebrew.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
|
||||||
@ -66,8 +66,8 @@ describe Homebrew::CLI::Parser do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "parses a comma array flag option" do
|
it "parses a comma array flag option" do
|
||||||
args = parser.parse(["--files=random1.txt,random2.txt"])
|
parser.parse(["--files=random1.txt,random2.txt"])
|
||||||
expect(args.files).to eq %w[random1.txt random2.txt]
|
expect(Homebrew.args.files).to eq %w[random1.txt random2.txt]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -96,14 +96,14 @@ describe Homebrew::CLI::Parser do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "raises no exception" do
|
it "raises no exception" do
|
||||||
args = parser.parse(["--flag1=flag1", "--flag2=flag2"])
|
parser.parse(["--flag1=flag1", "--flag2=flag2"])
|
||||||
expect(args.flag1).to eq "flag1"
|
expect(Homebrew.args.flag1).to eq "flag1"
|
||||||
expect(args.flag2).to eq "flag2"
|
expect(Homebrew.args.flag2).to eq "flag2"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises no exception for optional dependency" do
|
it "raises no exception for optional dependency" do
|
||||||
args = parser.parse(["--flag3=flag3"])
|
parser.parse(["--flag3=flag3"])
|
||||||
expect(args.flag3).to eq "flag3"
|
expect(Homebrew.args.flag3).to eq "flag3"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -146,14 +146,14 @@ describe Homebrew::CLI::Parser do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "raises no exception" do
|
it "raises no exception" do
|
||||||
args = parser.parse(["--switch-a", "--switch-c"])
|
parser.parse(["--switch-a", "--switch-c"])
|
||||||
expect(args.switch_a?).to be true
|
expect(Homebrew.args.switch_a?).to be true
|
||||||
expect(args.switch_c?).to be true
|
expect(Homebrew.args.switch_c?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises no exception for optional dependency" do
|
it "raises no exception for optional dependency" do
|
||||||
args = parser.parse(["--switch-b"])
|
parser.parse(["--switch-b"])
|
||||||
expect(args.switch_b?).to be true
|
expect(Homebrew.args.switch_b?).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user