<commit_before>var argv = require('yargs').argv;
var Bluebird = require('bluebird');
var path = require('path');

// since old versions of node can't do Object.assign :(
var mergeObjects = require('./utils/mergeObjects');

var requiringModule = module.parent.parent;

module.exports = function(inputOptions) {

  var defaultOptions = {
    printOutputFrame: true
  };

  var options = mergeObjects(defaultOptions, inputOptions || {});

  function printOutput(returnValue) {
    Bluebird.resolve(returnValue)
    .then(function (output) {
      if (options.printOutputFrame) {
        console.log('--------make-runnable-output--------');
      }
      console.log(output);
      if (options.printOutputFrame) {
        console.log('------------------------------------');
      }
    }).catch(printError);
  }

  function printError(error) {
      if (options.printOutputFrame) {
        console.log('--------make-runnable-error--------');
      }
      console.log(error);
      if (options.printOutputFrame) {
        console.log('------------------------------------');
      }
  }

  // if the requiring file is being run directly from the command line
  if (require.main === requiringModule) {
    var targetPropertyFound = false;

    function runFuncWithArgs(func, unnamedArgs) {
      var namedArgs = Object.assign({},argv);
      delete namedArgs._;
      delete namedArgs.$0;

      if (Object.keys(namedArgs).length > 0 && unnamedArgs.length > 0) {
        console.error('You cannot specify both named and unnamed arguments to the function');
        process.exit(1);
      } else if (Object.keys(namedArgs).length > 0) {
        //we have named arguments. Let's pass these as an object to the function
        printOutput(func(namedArgs));
      } else if (unnamedArgs.length > 0) {
        //we have 1 or more unnamed arguments. let's pass those as individual args to function
        printOutput(func.apply(null, unnamedArgs));
      } else {
        //no extra arguments given to pass to function. let's just run it
        printOutput(func());
      }<commit_msg>Added two new options: printOutput: boolean defaults to true, controls whether output is displayed or not(excluding errors), printErrorOutput: boolean defaults to true, controls whether errors are displayed or not<commit_after>var argv = require('yargs').argv;
var Bluebird = require('bluebird');
var path = require('path');

// since old versions of node can't do Object.assign :(
var mergeObjects = require('./utils/mergeObjects');

var requiringModule = module.parent.parent;

module.exports = function(inputOptions) {

  var defaultOptions = {
    printOutputFrame: true,
    printOutput: true,
    printErrorOutput: true
  };

  var options = mergeObjects(defaultOptions, inputOptions || {});

  function printOutput(returnValue) {
    Bluebird.resolve(returnValue)
    .then(function (output) {
      if (options.printOutput) {
        if (options.printOutputFrame) {
          console.log('--------make-runnable-output--------');
        }
        console.log(output);
        if (options.printOutputFrame) {
          console.log('------------------------------------');
        }
      }
    }).catch(printError);
  }

  function printError(error) {
    if (printErrorOutput) {
      if (options.printOutputFrame) {
        console.log('--------make-runnable-error--------');
      }
      console.log(error);
      if (options.printOutputFrame) {
        console.log('------------------------------------');
      }
    }
  }

  // if the requiring file is being run directly from the command line
  if (require.main === requiringModule) {
    var targetPropertyFound = false;

    function runFuncWithArgs(func, unnamedArgs) {
      var namedArgs = Object.assign({},argv);
      delete namedArgs._;
      delete namedArgs.$0;

      if (Object.keys(namedArgs).length > 0 && unnamedArgs.length > 0) {
        console.error('You cannot specify both named and unnamed arguments to the function');
        process.exit(1);
      } else if (Object.keys(namedArgs).length > 0) {
        //we have named arguments. Let's pass these as an object to the function
        printOutput(func(namedArgs));
      } else if (unnamedArgs.length > 0) {
        //we have 1 or more unnamed arguments. let's pass those as individual args to function
        printOutput(func.apply(null, unnamedArgs));
      } else {
        //no extra arguments given to pass to function. let's just run it
        printOutput(func());
      }
{'fraction_non_alphanumeric': 0.1554715302491103, 'fraction_numerical': 0.003113879003558719, 'mean_word_length': 2.4486196319018405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5117965', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1169, 'n_words': 344}