I think this is more succinct:
```ruby
def initialize(args, options)
  installed = Autoparts::Package.installed

  if options.include?('--json')
    puts JSON.generate installed.map { |p, v| { package: p, versions: v } }
  else
    puts "parts: no installed package found" and return if installed.empty?
    puts installed.map { |p, v| "#{p} (#{v.join(',')})" }
  end
end
```