Add a method for retrieving only flags from ARGV

This commit is contained in:
Jack Nagel 2014-08-29 19:38:32 -05:00
parent 6885f588d0
commit b14851903c
4 changed files with 11 additions and 2 deletions

View File

@ -186,7 +186,7 @@ begin
trap("INT", old_trap)
formula = ARGV.formulae.first
options = Options.create(ARGV.options_only)
options = Options.create(ARGV.flags_only)
build = Build.new(formula, options)
build.install
rescue Exception => e

View File

@ -7,6 +7,10 @@ module HomebrewArgvExtension
select { |arg| arg.start_with?("-") }
end
def flags_only
select { |arg| arg.start_with?("--") }
end
def formulae
require "formula"
@formulae ||= downcased_unique_named.map { |name| Formulary.factory(name, spec) }

View File

@ -36,7 +36,7 @@ class SoftwareSpec
@bottle_specification = BottleSpecification.new
@patches = []
@options = Options.new
@build = BuildOptions.new(Options.create(ARGV.options_only), options)
@build = BuildOptions.new(Options.create(ARGV.flags_only), options)
@compiler_failures = []
end

View File

@ -30,6 +30,11 @@ class ArgvExtensionTests < Homebrew::TestCase
assert_equal %w[--foo -vds], @argv.options_only
end
def test_flags_only
@argv << "--foo" << "-vds" << "a" << "b" << "cdefg"
assert_equal %w[--foo], @argv.flags_only
end
def test_empty_argv
assert_empty @argv.named
assert_empty @argv.kegs