<commit_before>const tmenu        = require('terminal-menu')
    , path         = require('path')
    , fs           = require('fs')
    , EventEmitter = require('events').EventEmitter

const printText = require('./print-text')
    , repeat    = require('./term-util').repeat
    , bold      = require('./term-util').bold

const title        = 'LEARN YOU THE NODE.JS FOR MUCH WIN!'

function showMenu (opts) {
  var emitter  = new EventEmitter()
    , menu     = tmenu({ width: opts.width, x: 3, y : 2 })
    , problems = require('../menu.json')

  menu.reset()
  menu.write(bold(title) + '\n')
  menu.write(repeat('-', opts.width) + '\n')
    
  problems.forEach(function (name, i) {
    var isDone = opts.completed.indexOf(name) >= 0
      , m      = '[COMPLETED]'

    name = (i + 1) + '. ' + name

    if (isDone)
      return menu.add(name + Array(65 - m.length - name.length + 1).join(' ') + m)
    else
      menu.add(name)
  })

  menu.write(repeat('-', opts.width) + '\n')
  menu.add(bold('HELP'))
  menu.add(bold('EXIT'))
  
  menu.on('select', function (label) {
    var name = label.replace(/(^\d+\. )|(\s{2}.*)/g, '')
    
    menu.close()

    if (name === bold('EXIT'))
      return emitter.emit('exit')
    if (name === bold('HELP')) {
      console.log()
      return printText(opts.appname, path.join(__dirname, '/usage.txt'))
    }

    emitter.emit('select', name)
  })

  menu.createStream().pipe(process.stdout)
  
  return emitter
}

module.exports = showMenu<commit_msg>replaced numbers with raquo<commit_after>const tmenu        = require('terminal-menu')
    , path         = require('path')
    , fs           = require('fs')
    , EventEmitter = require('events').EventEmitter

const printText = require('./print-text')
    , repeat    = require('./term-util').repeat
    , bold      = require('./term-util').bold

const title        = 'LEARN YOU THE NODE.JS FOR MUCH WIN!'

function showMenu (opts) {
  var emitter  = new EventEmitter()
    , menu     = tmenu({ width: opts.width, x: 3, y : 2 })
    , problems = require('../menu.json')

  menu.reset()
  menu.write(bold(title) + '\n')
  menu.write(repeat('-', opts.width) + '\n')
    
  problems.forEach(function (name, i) {
    var isDone = opts.completed.indexOf(name) >= 0
      , m      = '[COMPLETED]'

    name = name

    if (isDone)
      return menu.add(bold('»') + ' ' + name + Array(65 - m.length - name.length + 1).join(' ') + m)
    else
      menu.add(bold('»') + ' ' + name)
  })

  menu.write(repeat('-', opts.width) + '\n')
  menu.add(bold('HELP'))
  menu.add(bold('EXIT'))
  
  menu.on('select', function (label) {
    var name = label.replace(/(^[^»]+»[^\s]+ )|(\s{2}.*)/g, '')
    
    menu.close()

    if (name === bold('EXIT'))
      return emitter.emit('exit')
    if (name === bold('HELP')) {
      console.log()
      return printText(opts.appname, path.join(__dirname, '/usage.txt'))
    }

    emitter.emit('select', name)
  })

  menu.createStream().pipe(process.stdout)
  
  return emitter
}

module.exports = showMenu
{'fraction_non_alphanumeric': 0.19583883751651254, 'fraction_numerical': 0.004953764861294584, 'mean_word_length': 2.5303030303030303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1138607', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1029, 'n_words': 217}