<commit_before>var hapi = require('hapi');
var Joi = require('joi');
var hapiSwaggered = require('hapi-swaggered');
var hapiSwaggeredUi = require('hapi-swaggered-ui');
var bunyan = require('bunyan');

var log = bunyan.createLogger({
    name: 'sarapis-cli', level: 'debug', streams: [{
        stream: process.stdout, level: 'debug'
    }, {path: './sarapis-cli.log', level: 'debug'}]
});

var argv = require('yargs')
    .usage('Usage: $0 --solr-host [string] --solr-port [num]')
    .demand(['solr-host', 'solr-port'])
    .describe('solr-host', 'Specify the host address of the Solr instance to connect to.')
    .describe('solr-port', 'Specify the port of the Solr instance to connect to.')
    .describe('solr-core', 'Specify the core of the Solr instance to connect to.')
    .describe('solr-allow', 'Specify the methods to be allowed on the Solr instance.')
    .describe('solr-deny', 'Specify the parameters to be prohibited on the Solr instance..')
    .describe('proxy-port', 'Specify the port of the Solr proxy.')
    .describe('proxy-path', 'Specify the valid paths of the Solr proxy.')
    .describe('sarapis-port', 'Specify the port of this Sarapis server instance.')
    .version(function () {
        return require('./package.json').version;
    })
    .epilog('Copyright 2015')
    .argv;
log.info(argv);

var SOLR_HOST = argv.solrHost || 'localhost';
var SOLR_PORT = argv.solrPort || 8983;
var SOLR_CORE = argv.solrCore;
var SOLR_VALID_METHODS = argv.solrAllow || ['GET', 'HEAD'];
var SOLR_INVALID_PARAMS = argv.solrDeny || ['qt', 'stream'];
var PROXY_HOST = argv.proxyHost;
var PROXY_PORT = argv.proxyPort || 9090;
//var PROXY_PATH = argv.proxyPath != undefined ? argv.proxyPath.split(',') : [];
var PROXY_PATH = argv.proxyPath || ['/solr/select'];
var SARAPIS_PORT = argv.sarapisPort || 3000;

if (SOLR_CORE != undefined) {
    PROXY_PATH.push('/solr/' + SOLR_CORE + '/select')
}
log.info();


//var args = [];
//var DEBUG = process.env.DEBUG != undefined ? process.env.DEBUG.indexOf('solr-proxy') > 1 ? true : false : false;
//var PROXY_PORT = process.env.PROXY_PORT != undefined ? parseInt(process.env.PROXY_PORT) : 9090;
//var SOLR_HOST = process.env.SOLR_HOST != undefined ? process.env.SOLR_HOST : 'localhost';
//var SOLR_PORT = process.env.SOLR_PORT != undefined ? parseInt(process.env.SOLR_PORT) : 8080;
//var SOLR_VALID_METHODS = process.env.SOLR_VALID_METHODS != undefined ? process.env.SOLR_VALID_METHODS.split(',') : [];
//var SOLR_VALID_PATHS = process.env.SOLR_VALID_PATHS != undefined ? process.env.SOLR_VALID_PATHS.split(',') : [];
//var SOLR_INVALID_PARAMS = process.env.SOLR_INVALID_PARAMS != undefined ? process.env.SOLR_INVALID_PARAMS.split(',') : [];
//args.push(DEBUG, SOLR_HOST, SOLR_PORT, SOLR_VALID_METHODS, SOLR_VALID_PATHS, SOLR_INVALID_PARAMS);
//console.log(args);

//startup our proxy that we make our calls against
//we may even expose it to the outside world
var solrProxy = require('solr-proxy');
var solrProxyOptions = {
    listenPort: PROXY_PORT,
    validHttpMethods: SOLR_VALID_METHODS,
    validPaths: PROXY_PATH,
    invalidParams: SOLR_INVALID_PARAMS,
    backend: {
        host: SOLR_HOST,
        port: SOLR_PORT
    }
};
solrProxy.start(9090, solrProxyOptions);

var solrClient = require('solr-client');
var proxyClient = solrClient.createClient(PROXY_HOST, PROXY_PORT, SOLR_CORE);


var restServer = new hapi.Server();
restServer.connection({port: SARAPIS_PORT, labels: ['api']});<commit_msg>Tidy up argument setup<commit_after>var hapi = require('hapi');
var Joi = require('joi');
var hapiSwaggered = require('hapi-swaggered');
var hapiSwaggeredUi = require('hapi-swaggered-ui');
var bunyan = require('bunyan');

var log = bunyan.createLogger({
    name: 'sarapis-cli', level: 'debug', streams: [{
        stream: process.stdout, level: 'debug'
    }, {path: './sarapis-cli.log', level: 'debug'}]
});

var argv = require('yargs')
    .usage('Usage: $0 --solr-host [string] --solr-port [num]')
    .demand(['solr-host', 'solr-port'])
    .describe('solr-host', 'The host address of a Solr instance to connect to.')
    .describe('solr-port', 'The port of a Solr instance to connect to.')
    .describe('solr-core', 'A core of a Solr instance to connect to.')
    .describe('solr-allow', 'The methods to be allowed on the Solr instance(s).')
    .describe('solr-deny', 'The parameters to be prohibited on the Solr instance(s).')
    .describe('proxy-port', 'The port of the Solr proxy.')
    .describe('proxy-path', 'The valid paths for the Solr proxy.')
    .describe('sarapis-port', 'The port of this Sarapis server instance.')
    .version(function () {
        return require('./package.json').version;
    })
    .epilog('Copyright 2015 CPS Group\nhttp://cpsgroup.github.io/')
    .argv;
log.info(argv);

var SOLR_HOST = argv.solrHost || 'localhost';
var SOLR_PORT = argv.solrPort || 8983;
var SOLR_CORE = argv.solrCore;
var SOLR_VALID_METHODS = argv.solrAllow || ['GET', 'HEAD'];
var SOLR_INVALID_PARAMS = argv.solrDeny || ['qt', 'stream'];
var PROXY_HOST = argv.proxyHost;
var PROXY_PORT = argv.proxyPort || 9090;
var PROXY_PATH = argv.proxyPath || ['/solr/select'];
var SARAPIS_PORT = argv.sarapisPort || 3000;

if (SOLR_CORE != undefined) {
    PROXY_PATH.push('/solr/' + SOLR_CORE + '/select')
}
log.info();

//startup our proxy that we make our calls against
//we may even expose it to the outside world
var solrProxy = require('solr-proxy');
var solrProxyOptions = {
    listenPort: PROXY_PORT,
    validHttpMethods: SOLR_VALID_METHODS,
    validPaths: PROXY_PATH,
    invalidParams: SOLR_INVALID_PARAMS,
    backend: {
        host: SOLR_HOST,
        port: SOLR_PORT
    }
};
solrProxy.start(9090, solrProxyOptions);

var solrClient = require('solr-client');
var proxyClient = solrClient.createClient(PROXY_HOST, PROXY_PORT, SOLR_CORE);


var restServer = new hapi.Server();
restServer.connection({port: SARAPIS_PORT, labels: ['api']});
{'fraction_non_alphanumeric': 0.15452240067624684, 'fraction_numerical': 0.008622147083685545, 'mean_word_length': 4.263345195729538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1909585', 'n_tokens_mistral': 2132, 'n_tokens_neox': 2031, 'n_words': 508}