#!/usr/bin/env node
'use strict'
var abbrev = require('abbrev')
var minimist = require('minimist')
var pkg = require('../package.json')
var resize = require('../')

var opts = {
  alias: abbrev('help', 'input', 'output', 'version')
}

var argv = minimist(process.argv.slice(2), opts)

// minimist will produce an array of values for args with full --options
// smush it down to a single string that resize() can use
if (argv.input.constructor === Array) {
  argv.input = argv.input[0]
}
if (argv.output.constructor === Array) {
  argv.output = argv.output[0]
}

function help () {
  console.log([
    pkg.description,
    '',
    'Example',
    '  $ ios-icon-resize -i path/to/icon.png -o path/to/output/'
  ].join('\n'))
}

function cli (argv) {
  if (argv.help) {
    return help()
  }

  if (argv.version) {
    return console.log(pkg.version)
  }

  if (argv.input) {
    return resize(argv.input, argv.output)
  }

  console.error('Please specify an input icon file with the `-i` option.')

}

cli(argv)

@@ -282,285 +282,8 @@
 s)%0A%0A
-// minimist will produce an array of values for args with full --options%0A// smush it down to a single string that resize() can use%0Aif (argv.input.constructor === Array) %7B%0A  argv.input = argv.input%5B0%5D%0A%7D%0Aif (argv.output.constructor === Array) %7B%0A  argv.output = argv.output%5B0%5D%0A%7D%0A%0A
 func
@@ -584,24 +584,332 @@
 gv.input) %7B%0A
+    // minimist will produce an array of values for args with full --options%0A    // smush it down to a single string that resize() can use%0A    if (argv.input.constructor === Array) %7B%0A      argv.input = argv.input%5B0%5D%0A    %7D%0A    if (argv.output.constructor === Array) %7B%0A      argv.output = argv.output%5B0%5D%0A    %7D%0A
     return r

move argv.input check inside argv.input case