<commit_before>var prompt = require('..')
  , history = prompt.history
  , path = require('path');

var name = require('path').basename(process.argv[1]);

/**
 *  An infinite REPL style prompt with command history.
 */
var file = path.join(__dirname, '.history');
console.log('%s | send SIGINT (Ctrl^C) to exit', name);
console.log('%s | history file %s', name, file);
console.log('%s | experimental interpreter enabled (!!, !1 etc.)', name);

// write history file on exit
var opts = {file: file, exit: true};

history(opts, function(err, store, hs) {
  if(err) {
    console.error(err);
    process.exit(1);
  }

  // set up the prompt
  var ps = prompt({infinite: true});
  // tell the history file to mirror the readline history array
  store.mirror(ps.readline, null, true);
  ps.on('value', function(val, options, ps) {

    // handle interpreting !! etc. - EXPERIMENTAL
    if(Array.isArray(val)) {
      var histitem = store.interpret((val || []).join(' '));
      if(histitem) {
        options.value = histitem;
        return ps.run([options]);
      }
    }

    var history = store.history();<commit_msg>Update history example.<commit_after>var prompt = require('..')
  , history = prompt.history
  , path = require('path');

var name = require('path').basename(process.argv[1]);

/**
 *  An infinite REPL style prompt with command history.
 *
 *  Commands are written to `.history` in this directory.
 *
 *  Execute the program, run commands, quit and run again
 *  to view the history loaded from disc and assigned to the
 *  readline history.
 */
var file = path.join(__dirname, '.history');
console.log('%s | send SIGINT (Ctrl^C) to exit', name);
console.log('%s | history file %s', name, file);
console.log('%s | experimental interpreter enabled (!!, !1 etc.)', name);

// write history file on exit
var opts = {file: file, exit: true};

history(opts, function(err, store, hs) {
  if(err) {
    console.error(err);
    process.exit(1);
  }

  // set up the prompt
  var ps = prompt({infinite: true});
  // tell the history file to mirror the readline history array
  store.mirror(ps.readline, null, true);
  ps.on('value', function(val, options, ps) {

    // handle interpreting !! etc. - EXPERIMENTAL
    if(Array.isArray(val)) {
      var histitem = store.interpret((val || []).join(' '));
      if(histitem) {
        options.value = histitem;
        return ps.run([options]);
      }
    }

    var history = store.history();
{'fraction_non_alphanumeric': 0.16088199265006126, 'fraction_numerical': 0.002449979583503471, 'mean_word_length': 3.3209876543209877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7275647', 'n_tokens_mistral': 777, 'n_tokens_neox': 763, 'n_words': 235}