ARGV: extract #values from missing

This commit is contained in:
Alyssa Ross 2016-10-10 13:26:09 +01:00
parent a4dc835ba0
commit c4c855b9fc
3 changed files with 23 additions and 3 deletions

View File

@ -18,10 +18,8 @@ module Homebrew
ARGV.resolved_formulae ARGV.resolved_formulae
end end
hide = (ARGV.value("hide") || "").split(",")
ff.each do |f| ff.each do |f|
missing = f.missing_dependencies(hide: hide) missing = f.missing_dependencies(hide: ARGV.values("hide"))
next if missing.empty? next if missing.empty?
print "#{f}: " if ff.size > 1 print "#{f}: " if ff.size > 1

View File

@ -121,6 +121,13 @@ module HomebrewArgvExtension
flag_with_value.strip_prefix(arg_prefix) if flag_with_value flag_with_value.strip_prefix(arg_prefix) if flag_with_value
end end
# Returns an array of values that were given as a comma-seperated list.
# @see value
def values(name)
return unless val = value(name)
val.split(",")
end
def force? def force?
flag? "--force" flag? "--force"
end end

View File

@ -62,4 +62,19 @@ class ArgvExtensionTests < Homebrew::TestCase
assert !@argv.flag?("--frotz") assert !@argv.flag?("--frotz")
assert !@argv.flag?("--debug") assert !@argv.flag?("--debug")
end end
def test_value
@argv << "--foo=" << "--bar=ab"
assert_equal "", @argv.value("foo")
assert_equal "ab", @argv.value("bar")
assert_nil @argv.value("baz")
end
def test_values
@argv << "--foo=" << "--bar=a" << "--baz=b,c"
assert_equal [], @argv.values("foo")
assert_equal ["a"], @argv.values("bar")
assert_equal ["b", "c"], @argv.values("baz")
assert_nil @argv.values("qux")
end
end end