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

var argv = require('../src/process/argh').argv
var clr = require('../src/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))
<commit_msg>update task/runr — format changes not including time nor columns as with latest versions of ygor. keeping things simple. will use time within whatever build script  used by runr. columns is just extra for output display. will do  something different in the future. (maybe a command line help type of thing.)<commit_after>// adopted from: ygor <https://github.com/shannonmoeller/ygor>
// © 2016 <NAME> <EMAIL> (MIT)

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

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

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

  return exports
}

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

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

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
exports.error = error

process.nextTick(run.bind(null, cmd))

{'fraction_non_alphanumeric': 0.14603616133518776, 'fraction_numerical': 0.0037088548910523874, 'mean_word_length': 3.7849223946784925, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4757256', 'n_tokens_mistral': 705, 'n_tokens_neox': 693, 'n_words': 214}