<commit_before>// adopted from: ygor <https://github.com/shannonmoeller/ygor>
// © 2016 <NAME> <EMAIL> (MIT)

var argv = require('../process/argh').argv
var clr = require('../util/colorz')
var assert = require('assert')

var cmd = argv.argv || 'default'
var tasks = Object.create(null)

function logError (err) {
  console.error(err && err.stack || err)
}

function run (name) {
  if (!(name in tasks)) {
    console.log(clr.cyan('Tasks:\n  ') + clr.magenta(Object.keys(tasks).join('\n  ')))
    return
  }

  return Promise
    .resolve(tasks[name]())
    .catch(logError)
}

function task (name, callback) {
  assert(typeof name, 'string', 'Task name must be a string')
  assert(typeof callback, 'function', 'Task callback must be a function')

  tasks[name] = callback

  return exports
}

exports.run = run
exports.task = task
exports.args = argv

process.nextTick(run.bind(null, cmd))<commit_msg>update task/runr — change exports.args —> opts<commit_after>// adopted from: ygor <https://github.com/shannonmoeller/ygor>
// © 2016 <NAME> <EMAIL> (MIT)

var argv = require('../process/argh').argv
var clr = require('../util/colorz')
var assert = require('assert')

var cmd = argv.argv || 'default'
var tasks = Object.create(null)

function logError (err) {
  console.error(err && err.stack || err)
}

function run (name) {
  if (!(name in tasks)) {
    console.log(clr.cyan('Tasks:\n  ') + clr.magenta(Object.keys(tasks).join('\n  ')))
    return
  }

  return Promise
    .resolve(tasks[name]())
    .catch(logError)
}

function task (name, callback) {
  assert(typeof name, 'string', 'Task name must be a string')
  assert(typeof callback, 'function', 'Task callback must be a function')

  tasks[name] = callback

  return exports
}

exports.run = run
exports.task = task
exports.opts = argv

process.nextTick(run.bind(null, cmd))
{'fraction_non_alphanumeric': 0.16621253405994552, 'fraction_numerical': 0.004359673024523161, 'mean_word_length': 3.896, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 2, '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': '2080756', 'n_tokens_mistral': 631, 'n_tokens_neox': 620, 'n_words': 165}