#!/usr/bin/env node

if (!process.argv[2]) return console.error(
  'Usage: npm-me <username>'
)

var columnify = require('columnify')

require('./')(process.argv[2], function(err, downloads) {
  if (err) throw err
  downloads = downloads
  .filter(Boolean)
  .sort(function(a, b) {
    return a.count - b.count
  })

  console.log(columnify(downloads))

  var total = downloads.reduce(function(total, dl) {
    return total + dl.count
  }, 0)

  var max = downloads.reduce(function(max, dl) {
    return Math.max(max, dl.count)
  }, 0)

  var min = downloads.reduce(function(min, dl) {
    return Math.min(min, dl.count)
  }, 0)

  var avg = Math.round((max - min) / downloads.length)
  var stats = columnify([
      {name: 'Total', value: total}
    , {name: 'Max', value: max}
    , {name: 'Min', value: min}
    , {name: 'Avg', value: avg}
  ], {showHeaders: false})

  console.log()
  console.log('SUMMARY')
  console.log(stats)
})

@@ -534,156 +534,8 @@
 0)%0A%0A
-  var min = downloads.reduce(function(min, dl) %7B%0A    return Math.min(min, dl.count)%0A  %7D, 0)%0A%0A  var avg = Math.round((max - min) / downloads.length)%0A
   va
@@ -628,72 +628,8 @@
 ax%7D%0A
-    , %7Bname: 'Min', value: min%7D%0A    , %7Bname: 'Avg', value: avg%7D%0A
   %5D,

Remove min and avg, because useless.