diff --git a/lib/thor/parser/options.rb b/lib/thor/parser/options.rb index 8c1bbe7f2..7f004c3c5 100644 --- a/lib/thor/parser/options.rb +++ b/lib/thor/parser/options.rb @@ -149,9 +149,7 @@ def check_unknown! protected def assign_result!(option, result) - if option.repeatable && option.type == :hash - (@assigns[option.human_name] ||= {}).merge!(result) - elsif option.repeatable + if option.repeatable (@assigns[option.human_name] ||= []) << result else @assigns[option.human_name] = result diff --git a/spec/parser/options_spec.rb b/spec/parser/options_spec.rb index b1e50fbfa..fcf050445 100644 --- a/spec/parser/options_spec.rb +++ b/spec/parser/options_spec.rb @@ -417,7 +417,7 @@ def remaining it "allows multiple values if repeatable is specified" do create :attributes => Thor::Option.new("attributes", :type => :hash, :repeatable => true) - expect(parse("--attributes", "name:one", "foo:1", "--attributes", "name:two", "bar:2")["attributes"]).to eq({"name"=>"two", "foo"=>"1", "bar" => "2"}) + expect(parse("--attributes", "name:one", "foo:1", "--attributes", "name:two", "bar:2")["attributes"]).to eq([{"name"=>"one", "foo"=>"1"}, {"name"=>"two", "bar" => "2"}]) end end