From b14851903c258b62968581f26ab9537f89b37456 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Fri, 29 Aug 2014 19:38:32 -0500 Subject: [PATCH] Add a method for retrieving only flags from ARGV --- Library/Homebrew/build.rb | 2 +- Library/Homebrew/extend/ARGV.rb | 4 ++++ Library/Homebrew/software_spec.rb | 2 +- Library/Homebrew/test/test_ARGV.rb | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index c7211f0321..90f2fc199c 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -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 diff --git a/Library/Homebrew/extend/ARGV.rb b/Library/Homebrew/extend/ARGV.rb index 1bb0b97010..dd695e4cb0 100644 --- a/Library/Homebrew/extend/ARGV.rb +++ b/Library/Homebrew/extend/ARGV.rb @@ -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) } diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index bce6c7d844..3dbcc0cc57 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -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 diff --git a/Library/Homebrew/test/test_ARGV.rb b/Library/Homebrew/test/test_ARGV.rb index 7403acf7c8..fe50621cd5 100644 --- a/Library/Homebrew/test/test_ARGV.rb +++ b/Library/Homebrew/test/test_ARGV.rb @@ -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