Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/thor/parser/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/parser/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down