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)
 | 
			
		||||
 | 
			
		||||
  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
 | 
			
		||||
 | 
			
		||||
@ -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) }
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user