Skip to content

Commit f33af3b

Browse files
Repeatable hash type flags bugfix.
They treated like every other type now. Instead of merging each key/val into a hash, each flag is treated like it's own hash that should be put into an array. fixes rails#768
1 parent 6ba7901 commit f33af3b

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/thor/parser/options.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ def check_unknown!
149149
protected
150150

151151
def assign_result!(option, result)
152-
if option.repeatable && option.type == :hash
153-
(@assigns[option.human_name] ||= {}).merge!(result)
154-
elsif option.repeatable
152+
if option.repeatable
155153
(@assigns[option.human_name] ||= []) << result
156154
else
157155
@assigns[option.human_name] = result

spec/parser/options_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def remaining
417417

418418
it "allows multiple values if repeatable is specified" do
419419
create :attributes => Thor::Option.new("attributes", :type => :hash, :repeatable => true)
420-
expect(parse("--attributes", "name:one", "foo:1", "--attributes", "name:two", "bar:2")["attributes"]).to eq({"name"=>"two", "foo"=>"1", "bar" => "2"})
420+
expect(parse("--attributes", "name:one", "foo:1", "--attributes", "name:two", "bar:2")["attributes"]).to eq([{"name"=>"one", "foo"=>"1"}, {"name"=>"two", "bar" => "2"}])
421421
end
422422
end
423423

0 commit comments

Comments
 (0)