<commit_before>var fs = require('fs');
var rc = require('rc');
var path = require('path');

var defaultConf = {
    default_server: "",
    server        : {}
};

/**
 * @const
 * @type {string}
 */
var DEFAULT = 'default_server';
var COMMAND_ADD = 'add';
var COMMAND_LIST = 'list';
var COMMAND_HELP = 'help';
var COMMAND_DEFAULT = 'default';
var COMMAND_REMOVE = 'remove';

var rcName = 'mcap';

/**
 * Select operation to given command
 * @param command the operation
 * @param attr the config attributes
 */
function parse(command, attr) {
    if ( command === COMMAND_ADD ) {
        add(attr);
    }
    else if ( command === COMMAND_LIST ) {

        return list(attr);
    }
    else if ( command === COMMAND_REMOVE ) {
        return remove(attr);
    }
    else if ( command === COMMAND_DEFAULT ) {
        return setDefault(attr[ 0 ]);
    }
    else {
        return list(attr);
    }
}

/**
 * Add a server to the list
 * @param attr ['name', 'baseurl', 'username', 'password']
 * @returns {*}
 */
function add(attr) {

    if ( !attr || !Array.isArray(attr) || !attr[ 0 ] ) {
        return get();
    }

    var newServer = {};
    newServer[ attr[ 0 ] ] = {
        "baseurl" : attr[ 1 ] || '',
        "username": attr[ 2 ] || '',
        "password": attr[ 3 ] || ''
    };

    var conf = rc(rcName, _deepCopy(defaultConf), { server: newServer });

    if ( !conf[ DEFAULT ] ) {
        conf[ DEFAULT ] = attr[ 0 ];
    }

    return _save(conf);
}

/**
 * Returns all settings
 * no param will return all configurations - if param exists then return the specific one - if none is found return
 * false
 * @param param
 * @returns {*}
 */
function get(param) {
    try {
        var config = rc(rcName, _deepCopy(defaultConf), []);
        if ( !param ) {
            // get the config
            return config
        }
        else if ( config[ param ] ) {
            if ( param === DEFAULT ) {
                // return the default one if param is default
                return config[ config[ param ] ];
            }
            // return the param one
            return config[ 'server' ][ param ];
        }
        return false;
    } catch ( e ) {
        console.error(chalk.red(e));
    }
}

/**
 * Print all settings
 * @returns {*}
 */<commit_msg>fix for deploy and publish command<commit_after>var fs = require('fs');
var rc = require('rc');
var path = require('path');

var defaultConf = {
    default_server: "",
    server        : {}
};

/**
 * @const
 * @type {string}
 */
var DEFAULT = 'default_server';
var COMMAND_ADD = 'add';
var COMMAND_LIST = 'list';
var COMMAND_HELP = 'help';
var COMMAND_DEFAULT = 'default';
var COMMAND_REMOVE = 'remove';

var rcName = 'mcap';

/**
 * Select operation to given command
 * @param command the operation
 * @param attr the config attributes
 */
function parse(command, attr) {
    if ( command === COMMAND_ADD ) {
        add(attr);
    }
    else if ( command === COMMAND_LIST ) {

        return list(attr);
    }
    else if ( command === COMMAND_REMOVE ) {
        return remove(attr);
    }
    else if ( command === COMMAND_DEFAULT ) {
        return setDefault(attr[ 0 ]);
    }
    else {
        return list(attr);
    }
}

/**
 * Add a server to the list
 * @param attr ['name', 'baseurl', 'username', 'password']
 * @returns {*}
 */
function add(attr) {

    if ( !attr || !Array.isArray(attr) || !attr[ 0 ] ) {
        return get();
    }

    var newServer = {};
    newServer[ attr[ 0 ] ] = {
        "baseurl" : attr[ 1 ] || '',
        "username": attr[ 2 ] || '',
        "password": attr[ 3 ] || ''
    };

    var conf = rc(rcName, _deepCopy(defaultConf), { server: newServer });

    if ( !conf[ DEFAULT ] ) {
        conf[ DEFAULT ] = attr[ 0 ];
    }

    return _save(conf);
}

/**
 * Returns all settings
 * no param will return all configurations - if param exists then return the specific one - if none is found return
 * false
 * @param param
 * @returns {*}
 */
function get(param) {
    try {
        var config = rc(rcName, _deepCopy(defaultConf), []);
        if ( !param ) {
            // get the config
            return config;
        }
        else if(param === DEFAULT){
            var defaultServer = config[DEFAULT];
            return config['server'][defaultServer];
        }
        else if ( config['server'][ param ] ) {
            return config[ 'server' ][ param ];
        }
        return false;
    } catch ( e ) {
        console.error('Error on Get',chalk.red(e));
    }
}

/**
 * Print all settings
 * @returns {*}
 */
{'fraction_non_alphanumeric': 0.15236004390779365, 'fraction_numerical': 0.0030735455543358945, 'mean_word_length': 2.1573111573111574, 'pattern_counts': {'":': 4, '<': 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': '3965181', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1364, 'n_words': 410}