示例#1
0
module.exports = () => {
  const params = commandLineArgs(paramDefinitions);

  if (!params.version) {
    const usage = commandLineUsage([
      {
        content: 'Prepare a published canary release to be promoted to stable.',
      },
      {
        header: 'Options',
        optionList: paramDefinitions,
      },
      {
        header: 'Examples',
        content: [
          {
            desc: 'Example:',
            example:
              '$ ./prepare-stable.js [bold]{--version=}[underline]{0.0.0-ddaf2b07c}',
          },
        ],
      },
    ]);
    console.log(usage);
    process.exit(1);
  }

  return params;
};
function nodeservices() {
	var commandLineArgs = require("command-line-args");
	var args_definitions = [{
		name: "registry",
		alias: "r",
		type: Boolean
	},{
		name: "discovery",
		alias: "d",
		type: Boolean
	},{
		name: "registry-port",	
		type: String,
		defaultValue: 4001
	},{
		name: "discovery-port",	
		type: String,
		defaultValue: 4002
	}];

	var args = commandLineArgs(args_definitions);

	if (args.registry) {	
		require("./registry.js")(args["registry-port"]);
	}
	if (args.discovery) {
		require("./discovery.js")(args["discovery-port"]);
	}

	console.log("Everything is right. Be cool.");
}
示例#3
0
文件: install.js 项目: Karan-GM/core
function parseArguments() {
    var cliArgs = require("command-line-args");
    var cli = cliArgs([{
        name: "help",
        alias: "h",
        type: Boolean,
        description: "Help"
    }, {
        name: "catalyst-port",
        type: String,
        description: "Catalyst port number"
    }, {
        name: "db-host",
        type: String,
        description: "DB Host"
    }, {
        name: "db-port",
        type: String,
        description: "DB Port"
    }, {
        name: "db-name",
        type: String,
        description: "DB Port"
    }, {
        name: "ldap-host",
        type: String,
        description: "Ldap Host"
    }, {
        name: "ldap-port",
        type: String,
        description: "Ldap Host"
    }, {
        name: "seed-data",
        type: Boolean,
        description: "Restore Seed Data"
    }, {
        name: "ldap-user",
        type: Boolean,
        description: "Setup Ldap user"
    }, {
        name: "max-instance-count",
        type: Number,
        description: "Maximum number of instance allowed to be launch"
    }]);

    var options = cli.parse();

    /* generate a usage guide */
    var usage = cli.getUsage({
        header: "catalyst help",
        footer: "For more information, visit http://www.relevancelab.com"
    });

    if (options.help) {
        console.log(usage);
        process.exit(0);
    }
    return options;
}
示例#4
0
  self.processArgs = function(mapping) {
    mapping = mapping || getCommandArgsMapping();

    var args = commandLineArgs(mapping);
    var settings = getSettings(args);
    validateSettings(settings);

    return settings;
  }
示例#5
0
function getArgs(flags) {
	const argv = commandLineArgs(flags, {
		partial: true,
	});

	if (!argv.loglevel) argv.loglevel = "info"; // The default value handling in the library is buggy
	if (argv.loglevel === "verbose") argv.loglevel = "verb";
	if (argv.loglevel === "warning") argv.loglevel = "warn";

	return argv;
}
示例#6
0
function getConfig() {
  const config = dotenv.config().parsed;

  config.cpuNumber = cpus().length;

  return Object.assign(
    config,
    getDefaultFromPackage(),
    getMySQlConnectionString(),
    commandLineArgs(argumentDefinitions)
  );
}
	function commandLineOptions()
	{	var cli=commandLineArgs(optionDefinations);

		if((cli.firstYear==undefined)||(cli.secondYear==undefined))
		{	console.log({
				title:"Usage",
				description:"Enter options ",
			});
			process.exit();
		}
		else
			return cli;
	}
	function commandLineOptions()
	{	var cli=commandLineArgs(optionDefinations);

		if(cli.Search==undefined)
		{	console.log({
				title:"Usage",
				description:"Options displayed below are required ",
			});
			process.exit();
		}
		else
			return cli;
	}
示例#9
0
文件: index.js 项目: vanniktech/Emoji
/**
 * Runs the script.
 * This is separated into three parts:
 * - Parsing the files.
 * - Copying (and optimizing) the images into the respective directories.
 * - Generating the java code and copying it into the respective directories.
 * All tasks apart from the parsing can be disabled through a command line parameter. If you want to skip the
 * optimization of the required files (It is assumed they are in place then) for example, you can pass --no-optimize to
 * skip the optimization step.
 * @returns {Promise.<void>} Empty Promise.
 */
async function run() {
    const options = commandLineArgs([
        {name: 'no-copy', type: Boolean},
        {name: 'no-optimize', type: Boolean,},
        {name: 'no-generate', type: Boolean}
    ]);

    const map = await parse();

    if (!options["no-copy"]) {
        await copyImages(map, targets, !options["no-optimize"]);
    }

    if (!options["no-generate"]) {
        await generateCode(map, targets);
    }
}
示例#10
0
function commandLineOptions() {

    var cli = commandLineArgs([
        { name: "overview", alias: "o", type: String}
    ]);

    var options = cli.parse()
    if (Object.keys(options).length < 1) {
        console.log(cli.getUsage({
            title: "Usage",
            description: "You must supply at least one option.  See below."
        }));
        process.exit();
    }

    return options;
}
示例#11
0
文件: app.js 项目: naitsirc/M101JS
function commandLineOptions() {

    var options = commandLineArgs([
        { name: "firstyear", alias: "f", type: Number },
        { name: "lastyear", alias: "l", type: Number },
        { name: "employees", alias: "e", type: Number },
        { name: "skip", type: Number, defaultValue: 0 },
        { name:"limit", type: Number, defaultValue: 20000 }
    ]);
        
    if(Object.keys(options).length < 1){
        console.log('you must supply command line args');
        process.exit();
    }

    return options;
    
}
function commandLineOptions() {

    var cli = commandLineArgs([
        {	name:"Year",alias:"y",type:Number	},
		{	name:"Rated",alias:"r",type:String	}
    ]);
    
    var options = cli.parse()
    if ( !(("Year" in options) && ("Rated" in options))) {
        console.log(cli.getUsage({
            title: "Usage",
            description: "options below are required."
        }));
        process.exit();
    }

    return options;
    
}
function commandLineOptions(){
    var cli = commandLineArgs([
        { name : "firstYear", alias:"f", type:Number},
        { name : "lastYear", alias:"l", type:Number},
        { name : "employees", alias:"e", type:Number},
        { name : "ipo", alias:"i", type:String}
    ]);

    var opt = cli.parse();

    if (!(("firstYear" in opt) && ("lastYear" in opt))) {
        console.log(cli.getUsage({
            title:'Usage',
            description: 'The first two options are mandatory'
        }));
        process.exit();
    }

    return opt;
}
示例#14
0
function commandLineOptions() {

    var cli = commandLineArgs([
        { name: "firstYear", alias: "f", type: Number },
        { name: "lastYear", alias: "l", type: Number },
        { name: "employees", alias: "e", type: Number }
    ]);

    var options = cli.parse()
    if ( !(("firstYear" in options) && ("lastYear" in options))) {
        console.log(cli.getUsage({
            title: "Usage",
            description: "The first two options below are required. The rest are optional."
        }));
        process.exit();
    }

    return options;

}
示例#15
0
function commandLineOptions(){
		
		var cli = commandLineArgs([
			{ name: 'firstYear',alias:'f', type: Number},
			{ name: 'lastYear',alias:'l', type:Number},
			{ name: 'employees',alias: 'e', type: Number},
			{ name: 'skip', type: Number, defaultValue : 0 },
			{ name :'limit', type: Number, defaultValue :2000}
		]);

		var options = cli.parse();
		if(!(('firstYear' in options) && ('lastYear' in options))){
			console.log(cli.getUsage({
				title: 'Usage',
				description : 'The first two optons are required'
			}));
			process.exit();
		}

		
		return options;
}
    value: function parse(argv) {
      if (argv) {
        argv = arrayify(argv);
      } else {
        argv = process.argv.slice(0);
        argv.splice(0, 2);
      }
      var commandName = argv.shift();
      var output = {};

      var commandDefinition = this.commands.find(function (c) {
        return c.name === commandName;
      });
      if (commandDefinition) {
        var cli = commandLineArgs(commandDefinition.definitions);
        output.name = commandName;
        output.options = cli.parse(argv);
      } else {
        output.error = 'Unknown command';
        output.command = commandName;
      }
      return output;
    }
示例#17
0
  getCommandLineArgs: function (customArgs) {
    var args = customArgs.concat(commonArgs);
    var cli = commandLineArgs(args);
    var options = cli.parse();

    if (options.config) {
      try {
        readConfigFile(options.config, options);
      } catch (e) {
        options.error = e.message;
      }
    } else if (!options.user) {
      try {
        readConfigFile('config.json', options);
      } catch (e) {
        options.error = 'No user name nor config file was provided. Defaulting to "config.json" also failed.';
      }
    }

    options.usage = cli.getUsage(args);

    return options;
  }
function main() {
    // parse command line args:
    // command: start, stop, restart
    // and flag --app-config-path and --db-config-path   

    // TODO replace current argParsing library with something that has this feature
    var cli = commandLineArgs([
        { name: 'command', type: String },
        { name: 'app-config-path', type: String },
        { name: 'db-config-path', type: String } ]);
    var options = cli.parse()
    
    var appConfigPath = options['app-config-path'];
    if (!appConfigPath) {
        throw Error("Need to provide path to the config file for the app!");
    }
    var dbConfigPath = options['db-config-path'];
    if (!dbConfigPath) {
        throw Error("Need to provide path to the config file for the db!");
    }    

    var appConfig = require(appConfigPath);
    var dbConfig = require(dbConfigPath);
    
    var commandMap = {
        start: startServices,
        stop: stopServices,
        restart: restartServices,
        remove: removeServices
    };
    var cmd = options['command'];
    if (! (cmd in commandMap) ) {
        throw Error("Provide a valid command: start, stop, restart, or remove.");
    }     
    commandMap[cmd](appConfig, dbConfig);
}
'use strict';

const pda = require('../index.js');
const args = require('command-line-args');

const cli = args([
   {
       name: 'help',
       type: Boolean,
       alias: 'h',
       description: 'Print usage'
   },
   {
       name: 'endpoints',
       type: String,
       alias: 'e',
       defaultOption: true,
       multiple: true,
       description: 'Application endpoints to analyze'
   },
   {
       name: 'dest-dir',
       type: String,
       alias: 'd',
       description: 'Output directory'
   }
]);

const usage = cli.getUsage({
    header: 'polymer-dependency-analyzer visualizes component dependencies in a polymer application',
    title: 'polymer-dependency-analyzer'
});
示例#20
0
var commandLineArgs = require('command-line-args')
var commandLineUsage = require('command-line-usage')
var http = require('../lib/main')

const config = new http.Config()

const optionList = [
  { name: 'help', alias: 'h', type: Boolean, description: 'Display this usage help.' },
  { name: 'port', alias: 'p', type: Number, description: 'Listen port number.', defaultValue: config.port() },
  { name: 'host', alias: 'a', type: String, description: 'Listen ip address or hostname.', defaultValue: config.host() },
  { name: 'root', alias: 'r', type: String, description: 'Root folder path.', defaultValue: config.root() },
  { name: 'config', alias: 'c', type: String, description: 'JSON configuration load file path.' },
  { name: 'dump', alias: 'd', type: String, description: 'Default JSON configuration save file path.' },
]

const options = commandLineArgs(optionList)

if (options.help) {
  console.log(commandLineUsage([
    {
      header: 'http-cli',
      content: 'Starts a simple HTTP server with CORS support.',
    },
    {
      header: 'Options',
      optionList: optionList,
    }
  ]))
  process.exit()
}
if (!process.env.FACEBOOK_VERIFY_TOKEN) {
    console.log('Error: Specify verify_token in environment');
    process.exit(1);
}

var Botkit = require('./lib/Botkit.js');
var os = require('os');
var commandLineArgs = require('command-line-args');
var localtunnel = require('localtunnel');
var fetch = require('node-fetch');

const cli = commandLineArgs([
      {name: 'lt', alias: 'l', args: 1, description: 'Use localtunnel.me to make your bot available on the web.',
      type: Boolean, defaultValue: false},
      {name: 'ltsubdomain', alias: 's', args: 1,
      description: 'Custom subdomain for the localtunnel.me URL. This option can only be used together with --lt.',
      type: String, defaultValue: null},
   ]);

const ops = cli.parse();
if(ops.lt === false && ops.ltsubdomain !== null) {
    console.log("error: --ltsubdomain can only be used together with --lt.");
    process.exit();
}

var controller = Botkit.facebookbot({
    debug: true,
    access_token: process.env.FACEBOOK_PAGE_ACCESS_TOKEN,
    verify_token: process.env.FACEBOOK_VERIFY_TOKEN,
});
示例#22
0
'use strict';

var commandLineArgs = require('command-line-args');

var cli = commandLineArgs([

    {
        name: 'api',
        alias: 'a',
        type: String
    }, {
        name: 'host',
        alias: 'h',
        type: String
    }, {
        name: 'port',
        alias: 'p',
        type: Number
    }

]).parse();

module.exports = cli;
示例#23
0
module.exports = argv => {
    const args = [
        {
            name: 'inputFile',
            type: String,
            alias: 'i',
            typeLabel: 'file',
            defaultValue: false,
            description:
                'Input file (YAML format, generated by `license-checker report`)',
        },
        {
            name: 'outputFile',
            type: String,
            alias: 'o',
            typeLabel: 'file',
            defaultValue: false,
            description: 'Output file (YAML format, does not need to exist)',
        },
        {name: 'help', alias: 'h', description: 'Print help', type: Boolean},
    ];

    const options = commandLineArgs(args, {argv});

    const {help, outputFile, inputFile} = options;

    if (help) {
        const getUsage = require('command-line-usage');

        const sections = [
            {
                header: 'Eccenca License Checker (consolidate)',
                content:
                    'Check if a consolidated report is up to date with a newly generated report.',
            },
            {
                header: 'Synopsis',
                content: [
                    '$ license-checker consolidate [--help] --input=<path> --output=<path>',
                ],
            },
            {
                header: 'Options',
                optionList: args,
            },
        ];

        console.log(getUsage(sections));
    } else {
        if (!inputFile) {
            throw new Error('You need to specify an output file');
        }

        if (!outputFile) {
            const mkdirp = require('mkdirp');

            const dir = dirname(outputFile);
            mkdirp.sync(dir);

            throw new Error('You need to specify an output file');
        }

        consolidate({inputFile, outputFile});
    }
};
示例#24
0
文件: cli.js 项目: 75lb/handbrake-js
#!/usr/bin/env node
'use strict'
const ansi = require('ansi-escape-sequences')
const commandLineArgs = require('command-line-args')
const hbjs = require('../')
const cliOptions = require('../lib/cli-options')
const util = require('util')

const handbrakeOptions = commandLineArgs(cliOptions)._all

function column (n, msg) {
  process.stdout.write(ansi.cursor.horizontalAbsolute(n) + msg)
}

function onProgress (progress) {
  column(1, progress.task + '  ')
  column(11, progress.percentComplete.toFixed(2) + '   ')
  column(22, progress.fps.toFixed(2) + '   ')
  column(32, progress.avgFps.toFixed(2) + '   ')
  column(42, progress.eta)
}

function halt (err) {
  console.error(ansi.format(util.inspect(err), 'red'))
  process.exitCode = 1
}

/* user intends to encode, so attach progress reporter (unless --verbose was passed) */
if (handbrakeOptions.input && handbrakeOptions.output) {
  const handbrake = hbjs.spawn(handbrakeOptions)
    .on('error', halt)
示例#25
0
#!/usr/bin/env node
'use strict'
var fs = require('fs')
var commandLineArgs = require('command-line-args')
var dope = require('console-dope')
var jsdoc2md = require('../')
var domain = require('domain')
var loadConfig = require('config-master')
var homePath = require('home-path')
var path = require('path')
var o = require('object-tools')
var cliData = require('../lib/cli-data')

var cli = commandLineArgs(cliData.definitions)
var usage = cli.getUsage(cliData.usage)

try {
  var argv = cli.parse()
} catch (err) {
  halt(err)
}

var dmdConfig = loadConfig('dmd')
var parseConfig = loadConfig('jsdoc-parse')
var jsdoc2mdConfig = loadConfig('jsdoc2md')

var config = o.extend(parseConfig, dmdConfig, jsdoc2mdConfig, argv._all)

if (config.template) {
  config.template = fs.readFileSync(config.template, 'utf8')
}
示例#26
0
文件: index.js 项目: abdullah/cliv
  .option("-f, --folder", "Folder name")
  .option("-s, --super", "Super template")
  .option("-r, --reverse", "Reverse field order in template")
  .parse(process.argv);

var args = program.args;
var cwd = process.cwd();

var optionDefinitions = [
  { name: "components", alias: "c", type: String, multiple: true },
  { name: "folder", alias: "f", type: String },
  { name: "super", alias: "s", type: Boolean },
  { name: "reverse", alias: "r", type: Boolean }
];

var options = commandLineArgs(optionDefinitions);

if (options.components && options.components.length) {
  createComponent();
} else {
  console.log("You should type the component name".red);
}

function createComponent() {
  var componentNames = options.components;
  var optionFolder = options.folder;
  var templateName = options.super
    ? "template-super.vue"
    : "template-simple.vue";
  templateName = options.reverse ? "reverse-" + templateName : templateName;
  var clivTemplate = fs.readFileSync(path.join(__dirname, templateName), {
(function () {
	"use strict";

	const pageWidth = 2000; // Magic number!
	const pageHeight = 3800;

	let Express = require('express');
	let path = require('path');
	let phantom = require("phantomjs-promise");
	let request = require("request");
	let async = require("async");
	let fs = require('fs');
	let commandLineArgs = require("command-line-args");

	let app = new Express();

	let cli = commandLineArgs([{
		name: "help",
		alias: "h",
		type: Boolean,
		defaultOption: true,
		description: "Display this message."
	}, {
		name: "port",
		alias: "p",
		type: Number,
		defaultValue: 3000,
		description: "(Default: 3000) Set the port what express listening."
	}, {
		name: "update_existed_stargazers",
		alias: "ues",
		type: Boolean,
		defaultValue: false,
		description: "(Default: false) Update project's stargazers including existed."
	}, {
		name: "phantomjs",
		type: Boolean,
		defaultValue: false,
		description: "The task to generate the image."
	}, {
		name: "readme",
		type: Boolean,
		defaultValue: false,
		description: "The task to update readme."
	}, {
		name: "updatestargazers",
		type: Boolean,
		defaultValue: false,
		description: "The task to update the count of the stargazers."
	}]);
	let options = cli.parse();
	let httpServer = "http://127.0.0.1:" + options.port + "/";

	let languages = [];
	let jsonData = JSON.parse(fs.readFileSync('./ux/WebFrontEndStack.json', "utf-8")); // Require will lock the file.

	/**
	 * Tiemout
	 * @param int ms
	 * @return Promise<any>	 
	 */
	function timeout(ms) {
		return new Promise((resolve, reject) => {
			setTimeout(resolve, ms, 'done');
		});
	}
	/**
	 * Recursion to generate readme
	 * @param object object
	 * @param string language
	 * @param int deep
	 * @return string	 
	 */
	function buildReadme(object, language, deep) {
		let deeper = deep + 1;
		let deepString = new Array(deeper).join("\t") + "- ";
		let ret = [];
		let lang = "";
		if (object.languages) {
			lang = object.languages[language];
		}
		lang = lang || object.name;

		ret.push((function (deepString, name, url, github) {
			let haveUrl = !!url;
			let haveGitHub = !!github;
			let ret = [];
			ret.push(deepString);
			ret.push((haveUrl ? "[" : "") + name + (haveUrl ? "](" + url + ")" : ""));
			ret.push((haveGitHub ? " [\[GitHub\]](" + github + ")" : ""));
			return ret.join("");
		})(deepString, lang, object.url, object.github));

		if (object.children) {
			object.children.map((value, index) => {
				ret.push(buildReadme(value, language, deeper));
			});
		}
		return ret.join("\n");
	}

	/**
	 * Update the stargazers of the GitHub repo
	 * Be careful! There have the rate limit!
	 * @see  https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
	 * @return Promise<any>
	 */
	function updatestargazers() {
		return new Promise((resolve, reject) => {

			function getGitHubApi(github) {
				let githubArray = github.split("/");
				// I want a sprintf T_T
				return "https://api.github.com/repos/" + githubArray[3] + "/" + githubArray[4];
			}


			let q = async.queue(function (object, callback) {
				if (!object.github || (!options.update_existed_stargazers && object.stargazers)) {
					callback(false);
					return;
				}
				let githubUrl = getGitHubApi(object.github);
				console.log("Getting " + githubUrl);
				request({
					url: githubUrl,
					headers: {
						"User-Agent": "https://github.com/unruledboy/WebFrontEndStack" // GitHub required user-agent
					}
				}, (err, res, body) => {
					if (!err && res.statusCode == 200) {
						let json = JSON.parse(body);
						if (json === null) {
							callback(false);
							return;
						}
						object.stargazers = json.stargazers_count;
						callback(true);
					} else {
						if (res.statusCode == 403) { // Out of API limit!
							console.error("Out of GitHub API limit!");
							console.error("The limit will be reset when " + new Date(res.headers['x-ratelimit-reset'] * 1000));
							q.kill();
							reject("Out of GitHub API limit!");
						}
						callback(false);
					}
				});

			}, 5);
			q.drain = function () {
				fs.writeFileSync('./ux/WebFrontEndStack.json', JSON.stringify(jsonData), "utf-8");
				resolve();
			};
			function addQueue(object) {
				q.push(object, (noErr) => {
					if (noErr) console.log(object.name + " = " + object.stargazers);
				});
				if (object.children) {
					object.children.forEach((val) => {
						addQueue(val);
					});
				}
			}
			addQueue(jsonData);

			return q;
		});
	}
	/**
	 * For running phantomjs to take a screenshot for the webpage
	 * @return Promise<any>
	 */
	function phantomjs(language) {
		let displayLanguage = language === "" ? "en" : language;
		let promise = new Promise((resolve, reject) => {
			return phantom.createAsync().then((phantom) => {
				return phantom.createPageAsync();
			}).then((objects) => {
				console.log("Setting viewportSize..");
				return objects.page.setAsync('viewportSize', {
					width: pageWidth,
					height: pageHeight
				});
			}).then((objects) => {
				console.log("Opening " + httpServer + "?locale=" + language + " for " + displayLanguage);
				return objects.page.openAsync(httpServer + "?locale=" + language);
			}).then((objects) => {
				console.log("Rendered HTML, the image will be saved after 2 seconds.");
				if (objects.ret[0] != "success") {
					throw objects.ret[0];
				}
				return timeout(2000).then(() => {
					return objects.page.renderAsync(path.join(__dirname, 'Web Front End Stack' + (language === "" ? "" : ".") + language + '.png'));
				});
			}).then((objects) => {
				console.log("The image(" + displayLanguage + ") saved successfully!");
				objects.page.close();
				objects.phantom.exit();
				resolve();
			});
		});
		return promise;

	}


	/**
	 * To rebuild the README.md
	 * @return Promise<any>
	 */
	function readme(language) {
		let extension = (language === "" ? "" : ".") + language;
		let promise = new Promise((resolve, reject) => {
			fs.readFile('./README' + extension + '.md', "utf-8", (err, content) => {
				if (err) return reject(err);
				resolve(content);
			});
		});
		return promise.then((fileContent) => {
			let ret = buildReadme(jsonData, language, 0);
			fileContent = fileContent.replace(/<\!--BUILD_START-->[\d\D]+?<\!--BUILD_END-->/, "{%BuildStart%}");
			fs.writeFileSync('./README' + extension + '.md', fileContent.replace("{%BuildStart%}", "<!--BUILD_START-->\n\n" + ret + "\n\n<!--BUILD_END-->", "utf-8"));
			console.log('Readme (' + language + ') built successfully!');
		});
	}


	/**
	 * To start an express server
	 * @return Promise<any>
	 */
	function server() {
		return new Promise((resolve, reject) => {
			return app
				.set('port', options.port)
				.set('view engine', 'html')
				.use(Express.static(path.join(__dirname, '/ux')))
				.use('/', function (req, res) {
					res.redirect('/WebFrontEndStack.htm?locale=' + req.query.locale);
				})
				.listen(options.port, function () {
					console.info('Express started on: http://127.0.0.1:' + options.port);
					resolve(app);
				});
		});
	}

	if (options.help) {
		let usage = cli.getUsage({
			title: "Generator"
		});
		console.log(usage);
		return;
	}

	let queue = [];
	queue.push(server());

	// Firstly, check languages.

	languages.push("");
	for (let item in jsonData.languages) {
		languages.push(item);
	}

	languages.map((val) => {
		if (options.phantomjs) {
			queue.push(phantomjs(val));
		}
		if (options.readme) {
			queue.push(readme(val));
		}
	});

	if (options.updatestargazers) {
		queue.push(updatestargazers());
	}

	let promise = Promise.all(queue);

	if (queue.length > 1) { // for somebody who only want to start the server.
		console.log("You can press Ctrl+C to exit if tasks finished.");
		promise.then(() => {
			console.log("OK!");
			process.exit(0);
		});
	}
})();
示例#28
0
    {name: 'help', alias: 'h', type: Boolean, description: 'Display this usage guide.', defaultValue: false},
    {name: 'server', alias: 's', type: ServerDetails, defaultValue: ServerDetails('localhost:5000'),
     description: 'OSRM routing server', typeLabel: '[underline]{hostname[:port]}'},
    {name: 'path', alias: 'p', type: String, defaultValue: '/route/v1/driving/{};{}',
     description: 'OSRM query path with {} coordinate placeholders, default /route/v1/driving/{};{}', typeLabel: '[underline]{path}'},
    {name: 'filter', alias: 'f', type: String, defaultValue: ['$.routes[0].weight'], multiple: true,
     description: 'JSONPath filters, default "$.routes[0].weight"', typeLabel: '[underline]{filter}'},
    {name: 'bounding-box', alias: 'b', type: BoundingBox, defaultValue: BoundingBox('5.86442,47.2654,15.0508,55.1478'), multiple: true,
     description: 'queries bounding box, default "5.86442,47.2654,15.0508,55.1478"', typeLabel: '[underline]{west,south,east,north}'},
    {name: 'max-sockets', alias: 'm', type: Number, defaultValue: 1,
     description: 'how many concurrent sockets the agent can have open per origin, default 1', typeLabel: '[underline]{number}'},
    {name: 'number', alias: 'n', type: Number, defaultValue: 10,
     description: 'number of query points, default 10', typeLabel: '[underline]{number}'},
    {name: 'queries-files', alias: 'q', type: String,
     description: 'CSV file with queries in the first row', typeLabel: '[underline]{file}'}];
const options = cla(optionsList);
if (options.help) {
    const banner =
          String.raw`  ____  _______  __  ___  ___  __  ___  ___  _________  ` + '\n' +
          String.raw` / __ \/ __/ _ \/  |/  / / _ \/ / / / |/ / |/ / __/ _ \ ` + '\n' +
          String.raw`/ /_/ /\ \/ , _/ /|_/ / / , _/ /_/ /    /    / _// , _/ ` + '\n' +
          String.raw`\____/___/_/|_/_/  /_/ /_/|_|\____/_/|_/_/|_/___/_/|_|  `;
    const usage = clu([
        { content: ansi.format(banner, 'green'), raw: true },
        { header: 'Run OSRM queries and collect results'/*, content: 'Generates something [italic]{very} important.'*/ },
        { header: 'Options', optionList: optionsList }
    ]);
    console.log(usage);
    process.exit(0);
}
示例#29
0
function start() {
	/* define the command-line options */
	var cli = cliArgs([ {
		name : "help",
		alias : "h",
		type : Boolean,
		description : "Print usage instructions"
	}, {
		name : "domain",
		alias : "d",
		type : String,
		defaultOption : true,
		description : "Domain (e.g., 'example.org'"
	}, {
		name : "config",
		alias : "c",
		type : String,
		description : "Path to a configuration file (based on config.json)"
	} ]);
	
	/* parse the supplied command-line values */
	var options = cli.parse();
	
	/* generate a usage guide */
	var usage = cli.getUsage({
		header : "Braid Server: a federated collaboration server",
		footer : "For more information, visit http://braid.io"
	});
	
	if (options.help || (!options.domain && !options.config)) {
		console.log(usage);
		process.exit();
	}
	
	var configPath = path.join(__dirname, 'config.json');
	if (options.config) {
		configPath = options.config;
	}
	console.log("Reading configuration from " + configPath);
	fs.readFile(configPath, 'utf8', function(err, data) {
		if (err) {
			console.log(err);
			process.exit();
		}
		config = JSON.parse(data);
		if (options.domain) {
			config.domain = options.domain;
		}
		if (!config.mongo.mongoUrl) {
			throw "Invalid configuration.  mongo.mongoUrl is mandatory";
		}
		config.mongo.mongoUrl = config.mongo.mongoUrl.split("{domain}").join(config.domain.split(".").join("_"));
		console.log("Braid server initializing for domain: " + config.domain);
		console.log("Configuration", config);
		if (!config.domain) {
			throw "You must specify a domain in the configuration";
		}
		config.client.capabilities = {
			auth : require('./braid-auth').clientCapabilities,
			roster : require('./braid-roster').clientCapabilities,
			federation : require('./braid-federation').clientCapabilities
		};
		config.federation.capabilities = {
			auth : require('./braid-auth').federationCapabilities,
			roster : require('./braid-roster').federationCapabilities,
			federation : require('./braid-federation').federationCapabilities
		};
		var server = new BraidServer();
		server.initialize(config);
		server.start(function() {});
	});
}
示例#30
0
var commandLineArgs = require('command-line-args');
var sql = require('mssql');

var host = 'THE-DB-HOST';
var user = '******';
var pwd = 'THE-PASSWORD';
var db = 'THE-DB';
 
var cli = commandLineArgs([
    { name: 'host', alias: 'h', type: String, defaultOption: host },
    { name: 'user', alias: 'u', type: String, defaultOption: user },
    { name: 'pwd', alias: 'p', type: String, defaultOption: pwd },
    { name: 'database', alias: 'd', type: String, defaultOption: db }
]);

var options = cli.parse();

// Unocomment when you need to debug
//console.log("options:\n" + JSON.stringify(options));

host = options.host;
user = options.user;
pwd = options.pwd;
db = options.database;

var connectString = "mssql://"+ user  +":"+ pwd + "@"+ host +"/"+ db;

// generic query to show existing database information:
var query = "SELECT * FROM master.dbo.sysdatabases;"; 

console.log("connectString is:\n" + connectString);