<commit_before>'use strict';

var node_path = require('path');
var comfort = require('comfort');


var context = {
    profile     : require('./profile'),
    neuropil    : require('./neuropil'),
    locale      : require('./i18n'),
    logger      : require('./logger')
};

var root = node_path.join( __dirname, '..', '..');

// Commander for CLI
// cli entrance
// cache commander instance
var commander = module.exports = comfort({
    command_root: node_path.join( root, 'lib', 'command'),
    option_root : node_path.join( root, 'lib', 'option'),
    root        : root,
    prevent_extensions: true,
    name        : 'cortex',

    logger: require('./logger'),
    context: context

}).on('complete', function(e) {
    var err = e.error;

    if(err){
        if ( err instanceof Error ) {
            // loggie will deal with `Error` instances
            this.logger.fatal(err);

        // error code
        } else if (typeof err === 'number') {
            this.logger.fatal('Not ok, exit code: ' + err);
        
        } else {
            this.logger.fatal( err.message || err );
        }<commit_msg>#256: commander: support exitcode<commit_after>'use strict';

var node_path = require('path');
var comfort = require('comfort');


var context = {
    profile     : require('./profile'),
    neuropil    : require('./neuropil'),
    locale      : require('./i18n'),
    logger      : require('./logger')
};

var root = node_path.join( __dirname, '..', '..');

// Commander for CLI
// cli entrance
// cache commander instance
var commander = module.exports = comfort({
    command_root: node_path.join( root, 'lib', 'command'),
    option_root : node_path.join( root, 'lib', 'option'),
    root        : root,
    prevent_extensions: true,
    name        : 'cortex',

    logger: require('./logger'),
    context: context

}).on('complete', function(e) {
    var err = e.error;

    if(err){
        if ( err instanceof Error ) {
            // loggie will deal with `Error` instances
            this.logger.fatal(err);

        // error code
        } else if (typeof err === 'number') {
            this.logger.fatal(err, 'Not ok, exit code: ' + err);
        
        } else {
            this.logger.fatal(err.exitcode, err.message || err );
        }
{'fraction_non_alphanumeric': 0.15933098591549297, 'fraction_numerical': 0.0030809859154929575, 'mean_word_length': 2.2286931818181817, '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': '4789029', 'n_tokens_mistral': 680, 'n_tokens_neox': 656, 'n_words': 178}