<commit_before>var Rc = require('rc');
var Commands = require('./commands');
var SDK = require('requiresafe-sdk');

var aliases = {
    'ls': 'list',
    'l': 'list',
    'h': 'help'
};

var proxy = process.env.https_proxy || process.env.HTTPS_PROXY || process.env.http_proxy || process.env.HTTP_PROXY;

// The main CLI method, accepts the command arguments and a callback
exports.run = function (args, callback) {

    if (typeof args === 'function') {
        callback = args;
        args = undefined;
    }

    var config = Rc('requiresafe', {
        token: ''
    }, args);
    // did the user specify a command?
    var passedCommand = config._[0];

    // figure out what the command was
    // default to `commands.help` if
    // not passed or not found
    var command = passedCommand && Commands[passedCommand] || Commands[aliases[passedCommand]];

    if (!command) {
        command = Commands.help;
    }

    config.api = new SDK({
        authToken: config.token,
        local: config.hasOwnProperty('local'),
        proxy: proxy
    });
    config.commands = Commands;

    // Run the requested command
    command.run(config, callback);
};
<commit_msg>allow overriding the api baseUrl<commit_after>var Rc = require('rc');
var Commands = require('./commands');
var SDK = require('requiresafe-sdk');

var aliases = {
    'ls': 'list',
    'l': 'list',
    'h': 'help'
};

var proxy = process.env.https_proxy || process.env.HTTPS_PROXY || process.env.http_proxy || process.env.HTTP_PROXY;

// The main CLI method, accepts the command arguments and a callback
exports.run = function (args, callback) {

    if (typeof args === 'function') {
        callback = args;
        args = undefined;
    }

    var config = Rc('requiresafe', {
        token: ''
    }, args);
    // did the user specify a command?
    var passedCommand = config._[0];

    // figure out what the command was
    // default to `commands.help` if
    // not passed or not found
    var command = passedCommand && Commands[passedCommand] || Commands[aliases[passedCommand]];

    if (!command) {
        command = Commands.help;
    }

    config.api = new SDK({
        baseUrl: config.baseUrl,
        authToken: config.token,
        local: config.local,
        proxy: proxy
    });
    config.commands = Commands;

    // Run the requested command
    command.run(config, callback);
};

{'fraction_non_alphanumeric': 0.13643996641477749, 'fraction_numerical': 0.0008396305625524769, 'mean_word_length': 2.677469135802469, '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': '6453825', 'n_tokens_mistral': 731, 'n_tokens_neox': 701, 'n_words': 208}