'use strict';

var argv = require('minimist')(process.argv.slice(2));
var pkg = require('./package.json');

function help() {
  var chalk = require('chalk');

  console.log([
    chalk.cyan(pkg.name) + chalk.gray(' v' + pkg.version),
    pkg.description,
    '',
    'Usage: ' + pkg.name + ' <url1> <url2> [<url3> ...] --variable <variable>',
    '',
    chalk.yellow('--variable, --var, -V') + '  Specify a required global variable',
    '',
    'Options:',
    chalk.yellow('--no-min,            ') + '  Do not minify output',
    chalk.yellow('--help,            -h') + '  Print usage information',
    chalk.yellow('--version,         -v') + '  Print version',
    ''
  ].join('\n'));
}

var variable = argv.var || argv.variable || argv.V;

if (argv.version || argv.v) {
  console.log(pkg.version);
} else if (argv.help || argv.h || argv._.length === 0) {
  help();
} else {
  if (argv._.length < 2) {
    console.error('More than 2 URLs required.');
    process.exit(1);
  }

  if (variable === undefined || variable === true) {
    console.error('--variable <variable> required.');
    process.exit(1);
  }

  var urls = argv._.map(function(el) {
    return '' + el;
  });

  console.log(require('./' + pkg.main)(variable, urls, {min: argv.min}));
}

@@ -870,20 +870,16 @@
 %0A%7D else 
-%7B%0A  
 if (argv
@@ -897,31 +897,36 @@
  2) %7B%0A  
-  console.error
+process.stderr.write
 ('More t
@@ -937,35 +937,49 @@
 2 URLs required.
-');
+%5Cn', function() %7B
 %0A    process.exi
@@ -987,19 +987,25 @@
 (1);%0A  %7D
-%0A%0A 
+);%0A%7D else
  if (var
@@ -1054,23 +1054,28 @@
 %7B%0A  
-  console.error
+process.stderr.write
 ('--
@@ -1103,19 +1103,33 @@
 equired.
-');
+%5Cn', function() %7B
 %0A    pro
@@ -1145,17 +1145,27 @@
 (1);%0A  %7D
-%0A
+);%0A%7D else %7B
 %0A  var u

use process.stderr.write instead of console.error