Add a method for retrieving only flags from ARGV
This commit is contained in:
parent
6885f588d0
commit
b14851903c
@ -186,7 +186,7 @@ begin
|
|||||||
trap("INT", old_trap)
|
trap("INT", old_trap)
|
||||||
|
|
||||||
formula = ARGV.formulae.first
|
formula = ARGV.formulae.first
|
||||||
options = Options.create(ARGV.options_only)
|
options = Options.create(ARGV.flags_only)
|
||||||
build = Build.new(formula, options)
|
build = Build.new(formula, options)
|
||||||
build.install
|
build.install
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
|
|||||||
@ -7,6 +7,10 @@ module HomebrewArgvExtension
|
|||||||
select { |arg| arg.start_with?("-") }
|
select { |arg| arg.start_with?("-") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def flags_only
|
||||||
|
select { |arg| arg.start_with?("--") }
|
||||||
|
end
|
||||||
|
|
||||||
def formulae
|
def formulae
|
||||||
require "formula"
|
require "formula"
|
||||||
@formulae ||= downcased_unique_named.map { |name| Formulary.factory(name, spec) }
|
@formulae ||= downcased_unique_named.map { |name| Formulary.factory(name, spec) }
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class SoftwareSpec
|
|||||||
@bottle_specification = BottleSpecification.new
|
@bottle_specification = BottleSpecification.new
|
||||||
@patches = []
|
@patches = []
|
||||||
@options = Options.new
|
@options = Options.new
|
||||||
@build = BuildOptions.new(Options.create(ARGV.options_only), options)
|
@build = BuildOptions.new(Options.create(ARGV.flags_only), options)
|
||||||
@compiler_failures = []
|
@compiler_failures = []
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,11 @@ class ArgvExtensionTests < Homebrew::TestCase
|
|||||||
assert_equal %w[--foo -vds], @argv.options_only
|
assert_equal %w[--foo -vds], @argv.options_only
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_flags_only
|
||||||
|
@argv << "--foo" << "-vds" << "a" << "b" << "cdefg"
|
||||||
|
assert_equal %w[--foo], @argv.flags_only
|
||||||
|
end
|
||||||
|
|
||||||
def test_empty_argv
|
def test_empty_argv
|
||||||
assert_empty @argv.named
|
assert_empty @argv.named
|
||||||
assert_empty @argv.kegs
|
assert_empty @argv.kegs
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user