```ruby
output << { package: package, versions: versions }

if json_mode
  puts JSON.generate(json_output)
else
  output.each { |o| puts "#{o[:package]} (#{o[:versions].join ', '})" }
end
```