Implement ARGV.named in terms of ARGV.options_only
This commit is contained in:
parent
7a5e4f5cca
commit
e18da89f3c
@ -1,10 +1,10 @@
|
|||||||
module HomebrewArgvExtension
|
module HomebrewArgvExtension
|
||||||
def named
|
def named
|
||||||
@named ||= reject{|arg| arg[0..0] == '-'}
|
@named ||= self - options_only
|
||||||
end
|
end
|
||||||
|
|
||||||
def options_only
|
def options_only
|
||||||
select {|arg| arg[0..0] == '-'}
|
select { |arg| arg.start_with?("-") }
|
||||||
end
|
end
|
||||||
|
|
||||||
def formulae
|
def formulae
|
||||||
|
@ -21,8 +21,13 @@ class ArgvExtensionTests < Homebrew::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_argv_named
|
def test_argv_named
|
||||||
@argv << 'mxcl' << '--debug' << '-v'
|
@argv << "foo" << "--debug" << "-v"
|
||||||
assert_equal 1, @argv.named.length
|
assert_equal %w[foo], @argv.named
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_options_only
|
||||||
|
@argv << "--foo" << "-vds" << "a" << "b" << "cdefg"
|
||||||
|
assert_equal %w[--foo -vds], @argv.options_only
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_empty_argv
|
def test_empty_argv
|
||||||
|
Loading…
x
Reference in New Issue
Block a user