text: // Generated by CoffeeScript 1.7.1
  (function() {
    var doctest, keys, options, program, validators, _;
  
    program = require('commander');
  
    _ = require('underscore');
  
    doctest = require('../lib/doctest');
  
    program.version(doctest.version).usage('[options] path/to/js/or/coffee/module').option('-m, --module <type>', 'specify module system ("amd" or "commonjs")').option('-p, --print', 'output the rewritten source without running tests').option('-s, --silent', 'suppress output').option('-t, --type <type>', 'specify file type ("coffee" or "js")').parse(process.argv);
  
    validators = {
      module: _.partial(_.contains, [void 0, 'amd', 'commonjs']),
      print: _.constant(true),
      silent: _.constant(true),
      type: _.partial(_.contains, [void 0, 'coffee', 'js'])
    };
  
    keys = _.keys(validators).sort();
  
    options = _.pick(program, keys);
  
    _.each(keys, function(key) {
      if (!validators[key](options[key])) {
        process.stderr.write("\n  error: invalid " + key + " `" + options[key] + "'\n\n");
        return process.exit(1);
      }
    });
  
    process.exit(_.reduce(program.args, function(failures, path) {
      var err, results;
      try {
        results = doctest(path, options);
      } catch (_error) {
        err = _error;
        process.stderr.write("\n  error: " + (err.message[0].toLowerCase()) + err.message.slice(1) + "\n\n");
        process.exit(1);
      }
      return failures + _.reject(_.map(results, _.first), _.identity).length;
    }, 0));
  
  }).call(this);
  