Move handling of leading dashes to Options.create

This commit is contained in:
Jack Nagel 2014-08-29 19:38:32 -05:00
parent 7adbb1ccb9
commit 6885f588d0
2 changed files with 2 additions and 8 deletions

View File

@ -38,8 +38,6 @@ class Option
[name, "-#{name}"]
when /^-[a-zA-Z]$/
[name[1..1], name]
when /^--(.+)$/
[$1, name]
else
[name, "--#{name}"]
end
@ -55,6 +53,8 @@ class Options
case e
when /^-[^-]+$/
e[1..-1].split(//).each { |o| options << Option.new(o) }
when /^--(.+)$/
options << Option.new($1)
else
options << Option.new(e)
end

View File

@ -19,12 +19,6 @@ class OptionTests < Homebrew::TestCase
refute_eql @option, bar
end
def test_strips_leading_dashes
option = Option.new("--foo")
assert_equal "foo", option.name
assert_equal "--foo", option.flag
end
def test_description
assert_empty @option.description
assert_equal "foo", Option.new("foo", "foo").description