Skip to content

Commit

Permalink
ARGV: extract #values from missing
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssais committed Oct 25, 2016
1 parent a4dc835 commit c4c855b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Library/Homebrew/cmd/missing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ def missing
ARGV.resolved_formulae
end

hide = (ARGV.value("hide") || "").split(",")

ff.each do |f|
missing = f.missing_dependencies(hide: hide)
missing = f.missing_dependencies(hide: ARGV.values("hide"))
next if missing.empty?

print "#{f}: " if ff.size > 1
Expand Down
7 changes: 7 additions & 0 deletions Library/Homebrew/extend/ARGV.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ def value(name)
flag_with_value.strip_prefix(arg_prefix) if flag_with_value
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?
flag? "--force"
end
Expand Down
15 changes: 15 additions & 0 deletions Library/Homebrew/test/test_ARGV.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,19 @@ def test_flag?
assert !@argv.flag?("--frotz")
assert !@argv.flag?("--debug")
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

0 comments on commit c4c855b

Please sign in to comment.