function parseCommandLine() { cli.enable('version', 'status'); cli.parse(options); return { args: cli.args, options: cli.options, }; }
interpret: function(args) { debug('Beep bop beep .. starting up..') cli.setArgv(args) cli.options = {} cli.enable('version', 'glob', 'help') cli.setApp(path.resolve(__dirname + '/../package.json')) var opts = cli.parse(options) command.run(opts) },
function setupHelp(languages) { cli.enable('help', 'status', 'version'); cli.setApp('mphfgen', '0.0.1'); cli.parse( { language: ['l', 'Language to target', languages, 'c'], hashfunc: ['a', 'Hash function to use', ['djb2', 'sdbm'], 'djb2'], }, [ 'generate', ]); }
exports.parse = function() { var cli = require('cli'); cli.enable('version'); cli.setApp($cm.name, $cm.version); var options = cli.parse( { file : [ 'f', 'Spec file', 'path', './spec.js' ], targets : [ false, 'Target in comma seperated list', 'string', 'all' ] }); $cm.build(options); };
casper.test.begin('parsing an empty argument list', 8, function(test) { var parsed = cli.parse(['--&é"à=42===42']); // clean test.assertEquals(parsed.args, [], 'parse() returns expected positional args array'); test.assertEquals(parsed.options, { '&é"à': "42===42" }, 'parse() returns expected options object'); test.assertEquals(parsed.get('&é"à'), "42===42", 'parse() handles options with exotic names'); test.assert(parsed.has('&é"à'), 'has() checks if an option is set'); // raw test.assertEquals(parsed.raw.args, [], 'parse() returns expected positional raw args array'); test.assertEquals(parsed.raw.options, { '&é"à': "42===42" }, 'parse() returns expected options raw object'); test.assertEquals(parsed.raw.get('&é"à'), "42===42", 'parse() handles raw options with exotic names'); test.assert(parsed.raw.has('&é"à'), 'has() checks if a raw option is set'); test.done(); });
casper.test.begin('parsing an empty argument list', 12, function(test) { var parsed = cli.parse([]); // clean test.assertEquals(parsed.args, [], 'parse() returns expected positional args array'); test.assertEquals(parsed.options, {}, 'parse() returns expected options object'); test.assertEquals(parsed.get(0), undefined, 'parse() does not return inexistant positional arg'); test.assertEquals(parsed.get('blah'), undefined, 'parse() does not return inexistant option'); test.assert(!parsed.has(0), 'has() checks if an arg is set'); test.assert(!parsed.has('blah'), 'has() checks if an option is set'); // raw test.assertEquals(parsed.raw.args, [], 'parse() returns expected positional args array'); test.assertEquals(parsed.raw.options, {}, 'parse() returns expected options object'); test.assertEquals(parsed.raw.get(0), undefined, 'parse() does not return inexistant positional arg'); test.assertEquals(parsed.raw.get('blah'), undefined, 'parse() does not return inexistant option'); test.assert(!parsed.raw.has(0), 'has() checks if a raw arg is set'); test.assert(!parsed.raw.has('blah'), 'has() checks if a raw option is set'); test.done(); });
casper.test.begin('parsing some options', 12, function(test) { var parsed = cli.parse(['--foo=bar', '--baz']); // clean test.assertEquals(parsed.args, [], 'parse() returns expected positional args array'); test.assertEquals(parsed.options, {foo: 'bar', baz: true}, 'parse() returns expected options object'); test.assertEquals(parsed.get('foo'), 'bar', 'parse() retrieve an option value'); test.assert(parsed.get('baz'), 'parse() retrieve boolean option flag'); test.assert(parsed.has("foo"), 'has() checks if an option is set'); test.assert(parsed.has("baz"), 'has() checks if an option is set'); // raw test.assertEquals(parsed.raw.args, [], 'parse() returns expected positional raw args array'); test.assertEquals(parsed.raw.options, {foo: 'bar', baz: true}, 'parse() returns expected options raw object'); test.assertEquals(parsed.raw.get('foo'), 'bar', 'parse() retrieve an option raw value'); test.assert(parsed.raw.get('baz'), 'parse() retrieve boolean raw option flag'); test.assert(parsed.raw.has("foo"), 'has() checks if a raw option is set'); test.assert(parsed.raw.has("baz"), 'has() checks if a raw option is set'); test.done(); });
casper.test.begin('parsing an basic argument list', 14, function(test) { var parsed = cli.parse(['foo', 'bar']); // clean test.assertEquals(parsed.args, ['foo', 'bar'], 'parse() returns expected positional args array'); test.assertEquals(parsed.options, {}, 'parse() returns expected options object'); test.assertEquals(parsed.get(0), 'foo', 'parse() retrieve first positional arg'); test.assertEquals(parsed.get(1), 'bar', 'parse() retrieve second positional arg'); test.assert(parsed.has(0), 'has() checks if an arg is set'); test.assert(parsed.has(1), 'has() checks if an arg is set'); test.assert(!parsed.has(2), 'has() checks if an arg is not set'); // raw test.assertEquals(parsed.raw.args, ['foo', 'bar'], 'parse() returns expected positional raw args array'); test.assertEquals(parsed.raw.options, {}, 'parse() returns expected raw options object'); test.assertEquals(parsed.raw.get(0), 'foo', 'parse() retrieve first positional raw arg'); test.assertEquals(parsed.raw.get(1), 'bar', 'parse() retrieve second positional raw arg'); test.assert(parsed.raw.has(0), 'has() checks if a arw arg is set'); test.assert(parsed.raw.has(1), 'has() checks if a arw arg is set'); test.assert(!parsed.raw.has(2), 'has() checks if a arw arg is not set'); test.done(); });
interpret: function (args) { cli.setArgv(args); cli.options = {}; cli.enable("version", "glob", "help"); cli.setApp(path.resolve(__dirname + "/../package.json")); var options = cli.parse(OPTIONS); // Use config file if specified var config; if (options.config) { config = exports.loadConfig(options.config); } switch (true) { // JSLint reporter case options.reporter === "jslint": case options["jslint-reporter"]: options.reporter = "./reporters/jslint_xml.js"; break; // CheckStyle (XML) reporter case options.reporter === "checkstyle": case options["checkstyle-reporter"]: options.reporter = "./reporters/checkstyle.js"; break; // Reporter that displays additional JSHint data case options["show-non-errors"]: options.reporter = "./reporters/non_error.js"; break; // Custom reporter case options.reporter !== undefined: options.reporter = path.resolve(process.cwd(), options.reporter); } var reporter; if (options.reporter) { reporter = loadReporter(options.reporter); if (reporter === null) { cli.error("Can't load reporter file: " + options.reporter); process.exit(1); } } // This is a hack. exports.run is both sync and async function // because I needed stdin support (and cli.withStdin is async) // and was too lazy to change tests. function done(passed) { /*jshint eqnull:true */ if (passed == null) return; // Patch as per https://github.com/visionmedia/mocha/issues/333 // fixes issues with piped output on Windows. // Root issue is here https://github.com/joyent/node/issues/3584 function exit() { process.exit(passed ? 0 : 2); } try { if (exports.getBufferSize()) { process.stdout.once('drain', exit); } else { exit(); } } catch (err) { exit(); } } done(exports.run({ args: cli.args, config: config, reporter: reporter, ignores: loadIgnores(options.exclude, options["exclude-path"]), extensions: options["extra-ext"], verbose: options.verbose, extract: options.extract, useStdin: {"-": true, "/dev/stdin": true}[args[args.length - 1]] }, done)); }
message: "Name for key file", default: "key.pem" },{ type: "input", name: "certFile", message: "Name for certificate file", default: "cert.der" }], }; var cliOptions = cli.parse({ // To test against the demo instance, pass --newReg "https://www.letsencrypt-demo.org/acme/new-reg" // To get a cert from the demo instance, you must be publicly reachable on // port 443 under the DNS name you are trying to get, and run test.js as root. newReg: ["new-reg", "New Registration URL", "string", "http://localhost:4000/acme/new-reg"], certKeyFile: ["certKey", "File for cert key (created if not exists)", "path", "cert-key.pem"], certFile: ["cert", "Path to output certificate (DER format)", "path", "cert.pem"], email: ["email", "Email address", "string", null], agreeTerms: ["agree", "Agree to terms of service", "boolean", null], domains: ["domains", "Domain name(s) for which to request a certificate (comma-separated)", "string", null], }); var state = { certPrivateKey: null, accountPrivateKey: null, newRegistrationURL: cliOptions.newReg, registrationURL: "", termsRequired: false, termsAgreed: null,
var colors = require('colors'); var cli = require('cli'); var app = require('./app'); cli.parse(null, ['run', 'about']); switch(cli.command) { case 'run': app.run(); break; case 'about': app.about(); break; }
#!/usr/bin/env node const cli = require('cli'), chokidar = require('chokidar'), devsync = require('../') const options = cli.parse({ cwd: ['c', 'Path to the library', 'file', './'], target: ['t', 'Path to the package(s) which has dependency', 'file', '../'], watch: ['w', 'Watch the library'], silent: ['s', 'Be quiet'] }) if (options.watch) { chokidar.watch(options.cwd, { ignored: [] // TODO: ignore some files }).on('all', (e, p) => { console.log(`Update detected: ${ p }`) devsync(options) }) } else { devsync(options) }
var merge = require('merge'); var MessageSender = require('./MessageSender.js'); var defaultOptions = { host: 'services.local.com', user: '******', password: '******', frameMax: 0, vhost: 'test', exchange: 'audit', messagesPerMinute: 60 }; cli.parse({ host: ['h', 'RabbitMQ host', 'string', defaultOptions.host], user: ['u', 'RabbitMQ user', 'string', defaultOptions.user], password: ['p', 'RabbitMQ password', 'string', defaultOptions.password], vhost: ['v', 'RabbitMQ VHost', 'string', defaultOptions.vhost], exchange: ['q', 'Destination exchange that will receive messages', 'string', defaultOptions.exchange], template: ['t', 'Message template', 'string'], messagesPerMinute: ['m', 'Messages per minute', 'string', defaultOptions.messagesPerMinute] }); cli.main(function(args, options) { var sender = new MessageSender(merge(defaultOptions, options), cli); cli.spinner('Sending message ' + (sender.options.template === null ? 'Hello World' : sender.options.template) + ' at rate ' + sender.options.messagesPerMinute + '/min '); sender.sendWithRetry(); });
*/ "use strict"; const cli = require( 'cli' ), yargs = require( 'yargs' ), chalk = require( 'chalk' ), express = require( 'express' ), gulp = require( 'gulp' ), handleIo = require( './utils/io-output' ), path = require( 'path' ), patternguide = require( './main' ); // option flags cli.parse({ cwd: [ 'Current Working Directory', 'string' ], requestProxy: [ 'rp', 'Request Proxy', 'string' ] }); cli.main(function ( args, opts ) { // consider making this dynamic off of file structure reads // but for now just keep it simple in an array. let definedModes = [ 'init', 'server' ]; cli.ok( 'Welcome to PatternGuide\'s Front-end Devlopment Workflow' ); // every mode class should have a `start` method args.map(function ( mode ) { if ( definedModes.indexOf( mode ) != -1 ) { let Module = require( path.join( __dirname, 'modes', mode ) ); new Module().start(); }
#!/usr/bin/env node 'use strict'; process.title = 'mongodb-backup'; var VERSION = require('../package.json').version; var cli = require('cli'); cli .parse({ verbose: [ false, ' Save internal reporting into a logfile', 'file' ], host: [ false, ' Specifies a resolvable hostname for the mongod', 'string' ], parser: [ 'p', ' Data parser (bson, json)', 'string', 'bson' ], out: [ 'o', ' Specifies the directory where saves the output', 'string', 'dump/' ], tar: [ 't', ' Pack files into a .tar file', 'string' ], collections: [ 'c', 'Specifies a collection to backup', 'string' ], query: [ 'q', 'Query that optionally limits the documents included', 'string' ], metadata: [ 'm', 'Save metadata of collections as Index, ecc' ], version: [ 'v', 'Display the current version' ] }); cli .main(function(args, options) { var self = this; if (options.version) { return console.log(process.title + ' v' + VERSION); } else if (args.length == 0 && !options.host) { self.fatal('Missing uri option'); }
} const url = RNPLAY_APP_URL + urlToken; opener(url); }); }; const ACTION_MAP = { authenticate: createConfig, create: createGitRepo, open: openAppInBrowser }; cli.parse({ authenticate: ['a', 'Authenticate to rnplay.org with a token'], create: ['c', 'Create a git remote for this application'], open: ['o', 'Opens the last created application in rnplay.org'] }); cli.main((args, options) => { const action = ACTION_MAP[getFirstTrueOption(options)]; if (!action) { cli.getUsage(); return; } action(cli) .catch((e) => { cli.error('Ooops, there has been an error: \n' + e.message); cli.info('If you are sure that you did nothing wrong, please file an issue at the rnplay-cli repo!');
var cli = require('cli'), async = require('async'), redis = require('redis'), VenueUtil = require('venue-util'), mongoose = require('mongoose'), JobQueue = require('../../lib/JobQueue').JobQueue, Attribution = require('venue-util/lib/Attribution.js'); cli.parse({ env:['e', 'Environment name: development|test|production.', 'string', 'production'], config_path:['c', 'Config file path.', 'string', '../../etc/conf'], _id:['i', 'Scrape id to pair/create', 'string', 'all'] }); cli.main(function (args, options) { var conf try { conf = require(options.config_path)[options.env] if (!conf) { throw new Exception('Config file not found') } } catch (ex) { cli.fatal('Config file not found. Using: ' + options.config_path) } var redisClient = redis.createClient(conf.redis.port, conf.redis.host); var jobQueue = new JobQueue('insiderpagesdetails', {redisClient:redisClient}) var ordrinMongoConnectionString = 'mongodb://' + conf.mongo.user + ':' + conf.mongo.password + '@' + conf.mongo.host + ':' + conf.mongo.port + '/' + conf.mongo.db var dbConn = mongoose.createConnection(ordrinMongoConnectionString);
]; /* * Set the app name and version, otherwise it defaults to the ones from the `cli` package */ cli.setApp('wpa-cli', packageJson.version); /* * Enable plugins */ cli.enable('version', 'status'); /* * Describe the required options */ cli.parse(options, commands); cli.main(function() { if (!this.options.path) { cli.fatal(msgs.argsError.noPath); return; } var path = wpa.formatPath(this.options.path); switch (this.command) { case 'install': wpa.install(path); break;
var cli = require("cli"); cli.parse({ random_stream: ["rs", "random stream", "path", "/dev/urandom"], csv: ["c", "csv file path", "path", "./testtable01.csv"], number: ["n", "number of lines", "number", 10] }); cli.main(function(args, options) { var fs = require("fs"); var count = 0; var fdR = fs.openSync(options.random_stream, "r"); var fdW = fs.openSync(options.csv, "w"); var buffer = new Buffer(150); while (count < options.number) { fs.readSync(fdR, buffer, 0, 150, null); var s = buffer.toString('base64'); var line = (count + "," + s + "\n"); var bufW = new Buffer(line); fs.writeSync(fdW, bufW, 0, bufW.length, null); count++; } // end of while }); // end of cli.main
callback.call(cli, results); } }; singleTest(); }; cli.setUsage( cli.app + ' [OPTIONS] <URL> <scenario>\n\n' + '\x1b[1mExample\x1b[0m:\n ' + ' ' + cli.app + ' --connections 100 ws://localhost:8080 myScenario.js' ); cli.parse({ connections: ['c', 'Single test for specified count of connections', 'int', '100'], connectionsList: ['l', 'Multiple tests for specified list count of connections (-l 1,10,100,1000)', 'string'], output: ['o', 'File to save JSON result', 'file'] }); cli.main(function (args, options) { if (args.length !== 2) { cli.fatal('Wrong number of arguments. Must be exactly 2 arguments! See `' + cli.app + ' -h` for details'); } var connections; if (options.connectionsList) { connections = options.connectionsList.split(','); multipleTest(args[0], args[1], connections, cli, function (result) { if (options.output) {
var cli = require('cli'), t = casper.test; t.comment('parse(), get(), has()'); (function(parsed) { t.assertEquals(parsed.args, [], 'parse() returns expected positional args array'); t.assertEquals(parsed.options, {}, 'parse() returns expected options object'); t.assertEquals(parsed.get(0), undefined, 'parse() does not return inexistant positional arg'); t.assertEquals(parsed.get('blah'), undefined, 'parse() does not return inexistant option'); t.assert(!parsed.has(0), 'has() checks if an arg is set'); t.assert(!parsed.has('blah'), 'has() checks if an option is set'); })(cli.parse([])); (function(parsed) { t.assertEquals(parsed.args, ['foo', 'bar'], 'parse() returns expected positional args array'); t.assertEquals(parsed.options, {}, 'parse() returns expected options object'); t.assertEquals(parsed.get(0), 'foo', 'parse() retrieve first positional arg'); t.assertEquals(parsed.get(1), 'bar', 'parse() retrieve second positional arg'); t.assert(parsed.has(0), 'has() checks if an arg is set'); t.assert(parsed.has(1), 'has() checks if an arg is set'); t.assert(!parsed.has(2), 'has() checks if an arg is not set'); })(cli.parse(['foo', 'bar'])); (function(parsed) { t.assertEquals(parsed.args, [], 'parse() returns expected positional args array'); t.assertEquals(parsed.options, {foo: 'bar', baz: true}, 'parse() returns expected options object'); t.assertEquals(parsed.get('foo'), 'bar', 'parse() retrieve an option value'); t.assert(parsed.get('baz'), 'parse() retrieve boolean option flag'); t.assert(parsed.has("foo"), 'has() checks if an option is set'); t.assert(parsed.has("baz"), 'has() checks if an option is set'); })(cli.parse(['--foo=bar', '--baz']));
#!/usr/bin/env node var fs = require('fs'); var config = require('./config.js'); var cli = require('cli'); var prompt = require('prompt'); var itslearning = require('./itslearning.js'); cli.setApp('its', '0.0.1'); cli.parse({ setup : ['s', 'Setup credentials and driver.'], notifications: ['n', 'List notifications.'], courses : ['c', 'List all courses with their corresponding id.'], inbox : ['i', 'List messages in your inbox.'], message : ['m', 'Read a specific message in the inbox.', 'number'], bulletins : ['b', 'List bulletings (news) for a single course id.', 'number'] }); var couldNotAuthenticate = function () { cli.error ('Authentication failed. Check your credentials.'); } var setup = function () { var configuration = new config(); var setupSchema = { properties: { username: { description: 'It\'sLearning username', required: true },
var cli = require('cli'); var cluster = require ('cluster'); var VoltClient = require('./lib/client'); var VoltConfiguration = require('./lib/configuration'); var VoltProcedure = require('./lib/query'); var VoltQuery = require('./lib/query'); var util = require('util'); var client = null; var resultsProc = new VoltProcedure('Results'); var initProc = new VoltProcedure('Initialize', ['int', 'string']); var voteProc = new VoltProcedure('Vote', ['long', 'int', 'long']); var options = cli.parse({ voteCount : ['c', 'Number of votes to run', 'number', 10000], clusterNode0 : ['h', 'VoltDB host (one of the cluster)', 'string', 'localhost'] }); var area_codes = [907, 205, 256, 334, 251, 870, 501, 479, 480, 602, 623, 928, 520, 341, 764, 628, 831, 925, 909, 562, 661, 510, 650, 949, 760, 415, 951, 209, 669, 408, 559, 626, 442, 530, 916, 627, 714, 707, 310, 323, 213, 424, 747, 818, 858, 935, 619, 805, 369, 720, 303, 970, 719, 860, 203, 959, 475, 202, 302, 689, 407, 239, 850, 727, 321, 754, 954, 927, 352, 863, 386, 904, 561, 772, 786, 305, 941, 813, 478, 770, 470, 404, 762, 706, 678, 912, 229, 808, 515, 319, 563, 641, 712, 208, 217, 872, 312, 773, 464, 708, 224, 847, 779, 815, 618, 309, 331, 630, 317, 765, 574, 260, 219, 812, 913, 785, 316, 620, 606, 859, 502, 270, 504, 985, 225, 318, 337, 774, 508, 339, 781, 857, 617, 978, 351, 413, 443, 410, 301, 240, 207, 517, 810, 278, 679, 313, 586, 947, 248, 734, 269, 989, 906, 616, 231, 612, 320, 651, 763, 952, 218, 507, 636, 660, 975, 816, 573, 314, 557, 417, 769, 601, 662, 228, 406, 336, 252, 984, 919, 980, 910, 828, 704, 701, 402, 308, 603, 908, 848, 732, 551, 201, 862,
casper.test.begin('parsing commands containing args and options', 30, function(test) { var parsed = cli.parse(['foo & bar', 'baz & boz', '--universe=42', '--lap=13.37', '--chucknorris', '--oops=false']); // clean test.assertEquals(parsed.args, ['foo & bar', 'baz & boz'], 'parse() returns expected positional args array'); test.assertEquals(parsed.options, { universe: 42, lap: 13.37, chucknorris: true, oops: false }, 'parse() returns expected options object'); test.assertEquals(parsed.get('universe'), 42, 'parse() can cast a numeric option value'); test.assertEquals(parsed.get('lap'), 13.37, 'parse() can cast a float option value'); test.assertType(parsed.get('lap'), "number", 'parse() can cast a boolean value'); test.assert(parsed.get('chucknorris'), 'parse() can get a flag value by its option name'); test.assertType(parsed.get('oops'), "boolean", 'parse() can cast a boolean value'); test.assertEquals(parsed.get('oops'), false, 'parse() can cast a boolean value'); test.assert(parsed.has(0), 'has() checks if an arg is set'); test.assert(parsed.has(1), 'has() checks if an arg is set'); test.assert(parsed.has("universe"), 'has() checks if an option is set'); test.assert(parsed.has("lap"), 'has() checks if an option is set'); test.assert(parsed.has("chucknorris"), 'has() checks if an option is set'); test.assert(parsed.has("oops"), 'has() checks if an option is set'); // drop() parsed.drop(0); test.assertEquals(parsed.get(0), 'baz & boz', 'drop() dropped arg'); parsed.drop("universe"); test.assert(!parsed.has("universe"), 'drop() dropped option'); test.assertEquals(parsed.args, ["baz & boz"], 'drop() did not affect other args'); test.assertEquals(parsed.options, { lap: 13.37, chucknorris: true, oops: false }, 'drop() did not affect other options'); // raw test.assertEquals(parsed.raw.args, ['foo & bar', 'baz & boz'], 'parse() returns expected positional raw args array'); test.assertEquals(parsed.raw.options, { universe: "42", lap: "13.37", chucknorris: true, oops: "false" }, 'parse() returns expected options raw object'); test.assertEquals(parsed.raw.get('universe'), "42", 'parse() does not a raw numeric option value'); test.assertEquals(parsed.raw.get('lap'), "13.37", 'parse() does not cast a raw float option value'); test.assertType(parsed.raw.get('lap'), "string", 'parse() does not cast a numeric value'); test.assert(parsed.raw.get('chucknorris'), 'parse() can get a flag value by its option name'); test.assertType(parsed.raw.get('oops'), "string", 'parse() can cast a boolean value'); test.assertEquals(parsed.raw.get('oops'), "false", 'parse() can cast a boolean value'); // drop() for raw parsed.raw.drop(0); test.assertEquals(parsed.raw.get(0), 'baz & boz', 'drop() dropped raw arg'); parsed.raw.drop("universe"); test.assert(!parsed.raw.has("universe"), 'drop() dropped raw option'); test.assertEquals(parsed.raw.args, ["baz & boz"], 'drop() did not affect other raw args'); test.assertEquals(parsed.raw.options, { lap: "13.37", chucknorris: true, oops: "false" }, 'drop() did not affect other raw options'); test.done(); });
#!/usr/bin/env node --max_old_space_size=4096 var tact = require('./tact/tact.js') var async = require('async') var _options = require('config').Client var cli = require('cli') var options = cli.parse({ sourceCorpusFile: ['s', 'source corpus file to train', 'file', './corpus/source.txt'], targetCorpusFile: ['t', 'target corpus file to be aligned', 'file', './corpus/target.txt'], sourceCorrectionsFile: ['a', 'source corrections file to train', 'file', './corrections/source.txt'], targetCorrectionsFile: ['b', 'target corrections file to be aligned', 'file', './corrections/target.txt'] }) function progress(percent) { cli.progress(percent) } tact.corpus.parseFiles(options.sourceCorrectionsFile, options.targetCorrectionsFile, function(corrections) { // console.time('training-1') // console.time('correctionsTable-1') tact.corpus.parseFiles(options.sourceCorpusFile, options.targetCorpusFile, function(corpus) { // console.time('corpusTable-1') var training = new tact.Training(_options, corpus, corrections) training.train(progress, progress, function() { // console.timeEnd('correctionsTable-1') }, function() { // console.timeEnd('corpusTable-1') }, function() {
const DEFAULT_REMOTE = 'origin'; const PACKAGE_PATH = 'package.json'; /* Enable CLI plugins */ cli.enable('help', 'version', 'status') /* Point package.json so CLI can grab name and version */ .setApp(`${__dirname}/package.json`) /* Set usage string */ .setUsage(msgs.usage); /* Set the available options */ cli.parse({ tag: ['t', msgs.help.tag, 'string', 'v%@'], message: ['m', msgs.help.message, 'string', 'Publish v%@'], force: ['f', msgs.help.force, 'bool', false], }); /* Main Entry */ cli.main(function(args, options) { const util = require('./src/util')(options); // Check arguments and grab version if (args.length === 0) error.fatal('ERR_NO_VERSION'); if (args.length > 1) error.fatal('ERR_TOO_MANY_ARGS'); fs.readFile(PACKAGE_PATH, (err, content) => { if (err) error.fatal('ERR_CANT_OPEN_PACKAGE_JSON'); // Parse the package.json
interpret: function(args) { cli.setArgv(args); cli.options = {}; cli.enable("version", "glob", "help"); cli.setApp(path.resolve(__dirname + "/../package.json")); var options = cli.parse(OPTIONS); // Use config file if specified var config; if (options.config) { config = exports.loadConfig(options.config); } switch (true) { // JSLint reporter case options.reporter === "jslint": case options["jslint-reporter"]: options.reporter = "./reporters/jslint_xml.js"; break; // CheckStyle (XML) reporter case options.reporter === "checkstyle": case options["checkstyle-reporter"]: options.reporter = "./reporters/checkstyle.js"; break; // Unix reporter case options.reporter === "unix": options.reporter = "./reporters/unix.js"; break; // Reporter that displays additional JSHint data case options["show-non-errors"]: options.reporter = "./reporters/non_error.js"; break; // Custom reporter case options.reporter !== undefined: options.reporter = path.resolve(process.cwd(), options.reporter); } var reporter; if (options.reporter) { reporter = loadReporter(options.reporter); if (reporter === null) { cli.error("Can't load reporter file: " + options.reporter); exports.exit(1); } } // This is a hack. exports.run is both sync and async function // because I needed stdin support (and cli.withStdin is async) // and was too lazy to change tests. function done(passed) { /*jshint eqnull:true */ if (passed == null) return; exports.exit(passed ? 0 : 2); } done(exports.run({ args: cli.args, config: config, reporter: reporter, ignores: loadIgnores({ exclude: options.exclude, excludePath: options["exclude-path"] }), extensions: options["extra-ext"], verbose: options.verbose, extract: options.extract, filename: options.filename, useStdin: { "-": true, "/dev/stdin": true }[args[args.length - 1]] }, done)); }
interpret: function (args) { cli.setArgv(args); cli.options = {}; cli.enable("version", "glob", "help"); cli.setApp(path.resolve(__dirname + "/../../package.json")); var options = cli.parse(OPTIONS); var config = loadConfig(options.config || findConfig()); switch (true) { // JSLint reporter case options.reporter === "jslint": case options["jslint-reporter"]: options.reporter = "../reporters/jslint_xml.js"; break; // CheckStyle (XML) reporter case options.reporter === "checkstyle": case options["checkstyle-reporter"]: options.reporter = "../reporters/checkstyle.js"; break; // Reporter that displays additional JSHint data case options["show-non-errors"]: options.reporter = "../reporters/non_error.js"; break; // Custom reporter case options.reporter !== undefined: options.reporter = path.resolve(process.cwd(), options.reporter); } var reporter; if (options.reporter) { reporter = loadReporter(options.reporter); if (reporter === null) { cli.error("Can't load reporter file: " + options.reporter); process.exit(1); } } var passed = exports.run({ args: cli.args, config: config, reporter: reporter, ignores: loadIgnores(), extensions: options["extra-ext"] }); // Avoid stdout cutoff in Node 0.4.x, also supports 0.5.x. // See https://github.com/joyent/node/issues/1669 function exit() { process.exit(passed ? 0 : 2); } try { if (!process.stdout.flush()) { process.stdout.once("drain", exit); } else { exit(); } } catch (err) { exit(); } }
// A simple rethinkdb access app. It allows for: // - The creation of tables // - The insertion of data // - Showing the content of a table // - Deletion of a table var cli = require('cli'), rdb = require('rethinkdb'), fs = require('fs'); options = cli.parse({ host: [ 'h', 'RethinkDB hostname', 'string', 'localhost' ], port: [ 'p', 'RethinkDB port', 'int', 28015 ], action: [ 'a', 'Action to perform (create, insert, get, delete)', 'string', 'get' ], table: [ 't', 'Table name', 'string', null ], datafile: [ 'f', 'RethinkDB datafile', 'string', null ] }); const util = require('util') var invalidcli = false; if(options.table != null) { switch(options.action) { case 'create': break; case 'insert': if((options.table == null) || (options.datafile == null)) { invalidcli = true; } case 'get': break; case 'delete': break;
, nowjs = require('now') , url = require('url') , nano = require('nano') , cli = require('cli') , moment = require('moment') , crypto = require('crypto') , request = require('request') , app , couch , db , logger = require('./logger') ; global.config = JSON.parse(fs.readFileSync(__dirname + '/config.json', 'utf-8')); cli.parse({port:['p', 'Listen on this port', 'number', 0]}); couch = nano(global.config.couchdb_url); db = couch.use(global.config.db.logger); //console.log(db); app = express.createServer(); app.configure(function () { app.use(express.cookieParser()); app.use(app.router); app.use(express.static(__dirname + "/public")); }); var homepage = fs.readFileSync(__dirname + '/public/index.html', 'utf-8'); var homepage_graph = fs.readFileSync(__dirname + '/public/index_graph.html', 'utf-8'); var everyone = nowjs.initialize(app);