How to use the optimist.usage function in optimist

To help you get started, we’ve selected a few optimist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github davidgraeff / scenecontrol / core / index.js View on Github external
require('./logging.js').init("Core");

// Print usage information, command line parameters
var configs = require('./config.js');
var optimist = require('optimist').usage('Usage: $0	 [options]')
	.options("h",{alias:"help"}).describe("h","Show this help")
	.options("v",{alias:"version"}).describe("v","Show version and other information as parsable json")
	.options("d",{alias:"debug"}).describe("d","Activate profiling and debug output")
	.options("i",{alias:"import"}).describe("i","Import json files from path")
	.options("o",{alias:"override"}).describe("o","Override existing documents when importing files with the same id+type")
	.options("e",{alias:"exit"}).describe("e","Do not enter the mainloop and exit after init")
	.options("drop",{}).describe("drop","Drop database content. Warning! This can't be undone! Only works with additional -e flag.")
	.options("dbname",{default:configs.runtimeconfig.databasename}).describe("dbname","Database name")
	.options("cport",{default:configs.runtimeconfig.controlport}).describe("cport","TCP Controlsocket port")
	.options("wport",{default:configs.runtimeconfig.websocketport}).describe("wport","Websocket Controlsocket port"),
	argv = optimist.argv;
	
// Show Help or Version info?
if (argv.help) {
	console.log(configs.aboutconfig.ABOUT_SERVICENAME+" "+configs.aboutconfig.ABOUT_VERSION);
	console.log("Please visit http://davidgraeff.github.com/scenecontrol for more information");
github qiemem / tsi / bin / tsi.js View on Github external
/// 
var readline = require('readline');
var util = require('util');
var vm = require('vm');

var Console = require('console').Console;
var builtinLibs = require('repl')._builtinLibs;
var typescript = require("typescript.api");
var options = require('optimist').usage('A simple typescript REPL.\nUsage: $0').alias('h', 'help').describe('h', 'Print this help message').alias('f', 'force').describe('f', 'Force tsi to evaluate code with typescript errors.').alias('v', 'verbose').describe('v', 'Print compiled javascript before evaluating.'), argv = options.argv;

if (argv.h) {
    options.showHelp();
    process.exit(1);
}

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

// Much of this function is from repl.REPLServer.createContext
function createContext() {
    var context;
    context = vm.createContext();
    for (var g in global)
github howech / gestalt / lib / args.js View on Github external
ConfigArgs.super_.call(this,options);
    format = this._options_.format;

    if( format ) {
	this._options_.parser = this._options_.parser || parsers[ format ];
    }

    var source = this._options_.source;
    // setting argv in the options can override using optimist to get command line options
    var args = this._options_.argv;
    var argv;
    if( args ) {
	this._optimist_ = require('optimist')(args)
	    .usage(this._options_.optimist_usage, this._options_.optimist_options );
    } else {
	this._optimist_ = require('optimist')
	    .usage(this._options_.optimist_usage, this._options_.optimist_options );
    }

    argv = this._optimist_.argv;

    _.each(argv, function(val,key) {
        self.set(key,val, source +":"+key);
    });    
}
github BryanDonovan / node-cache-manager / test / run.js View on Github external
#!/usr/bin/env node
process.env.NODE_ENV = 'test';
require('../index');

var Mocha = require('mocha');
var optimist = require('optimist');
var walkDir = require('./support').walkDir;

var argv = optimist
.usage("Usage: $0 -t [types] --reporter [reporter] --timeout [timeout]")['default'](
    {types: 'unit,functional', reporter: 'spec', timeout: 6000})
    .describe('types', 'The types of tests to run, separated by commas. E.g., unit,functional,acceptance')
    .describe('reporter', 'The mocha test reporter to use.')
    .describe('timeout', 'The mocha timeout to use per test (ms).')
    .boolean('help')
    .alias('types', 'T')
    .alias('timeout', 't')
    .alias('reporter', 'R')
    .alias('help', 'h')
    .argv;

var mocha = new Mocha({timeout: argv.timeout, reporter: argv.reporter, ui: 'bdd'});

var validTestTypes = ['unit', 'functional', 'acceptance', 'integration'];
var requestedTypes = argv.types.split(',');
github ngnjs / NGN / bin / lib / commands / help.js View on Github external
var cli = require('optimist'),
    wrapwidth = 60,
    wrap = require('wordwrap')(wrapwidth);
require('colors');

var argv = cli
		.usage('Usage: ngn help ')
		.describe('command'.bold,'Specify a command to view it\'s help. For example,\n'+'ngn help install'.blue.bold+' or '+'ngn help init'.blue.bold+'.')
		.check(function(argv){
			if (argv.help === true){
				throw('');
			}
		})
		.argv;

console.log('');
switch(argv.help){
  case 'configure':
    console.log('The configuration wizard asks the following questions:\n');
    var data = [{
      q: 'Server Name',
      c: 'This is the descriptive name/title of this server. This should be unique within a group of servers.',
github caseywebdev / cogs / lib / cli.js View on Github external
getArgv: _.memoize(function () {
    var argv = _.reduce(
      optimist.usage(this.usage).options(this.options).argv,
      function (argv, val, key) {
        if (val) argv[key] = val;
        return argv;
      },
      {}
    );

    if (argv.watch) argv.watch = argv.watch.split(',');
    if (argv.options) argv.options = JSON.parse(argv.options);

    return argv;
  })
});
github MobileChromeApps / mobile-chrome-apps / src / cca.js View on Github external
function parseCommandLine() {
  var pathToApp = '<' + path.join('path', 'to', 'app') + '>';
  commandLineFlags = optimist
      .usage('Usage: $0  [commandArgs]\n' +
             '\n' +
             'checkenv - Ensures that your environment is setup correctly.\n' +
             '    Example:\n' +
             '        cca checkenv\n' +
             '\n' +
             'create  [--android] [--ios] [--copy-from=' + pathToApp + ' | --link-to=' + pathToApp + '] - Creates a project.\n' +
             '    Details:\n' +
             '        : The directory to create the project in.\n' +
             '        --android: Add the Android platform (default if android SDK is detected).\n' +
             '        --ios: Add the iOS platform (default if Xcode is detected).\n' +
             '        --copy-from=' + pathToApp + ': Create a project based on the given Chrome App.\n' +
             '        --link-to=' + pathToApp + ': Create a project that symlinks to the given Chrome App.\n' +
             '\n' +
             'platform [{add|remove|rm} ] ..... add or remove a specified PLATFORM, OR\n' +
             '         [{list|ls}] ...................... list all installed and available platforms\n' +
github mozilla / vtt.js / bin / cue2json.js View on Github external
* Copyright 2013 vtt.js Contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

var opt = require("optimist")
    .usage("Parse VTT files into JSON.\n" +
           "Usage: $0 [options]")
    .demand("v")
    .options("v", {
      alias: "vtt",
      describe: "Path to a VTT file or directory that contains VTT files to be processed."
    })
    .options("c", {
      alias: "copy",
      describe: "Copies output to a JSON file with the same name as the source VTT file."
    })
    .options("p", {
      alias: "process",
      describe: "Generate JSON from running the WebVTT processing model. Default is JSON from the WebVTT parser."
    })
    .options("n", {
github AudienseCo / node-geonames / utils / import_geonames.js View on Github external
var argv = require('optimist')
  .usage('Usage: $0 -f [geonamesFile] -d [mongodb://localhost/database] -r false')
  .demand(['f', 'd', 'r'])
  .alias('f', 'file')
  .describe('f', 'Path to a Geonames data, e.g. /tmp/AllCountries.txt')
  .alias('d', 'database')
  .describe('d', 'Mongo DB URI, e.g. mongodb://localhost/database')
  .alias('r', 'reset')
  .describe('r', 'Where to clean the database before importing, use true to clean it')
  .argv;

var
	mongoose = require('mongoose'),
	async = require('async'),
	Geoname = require('../models/Geoname')(argv.database);

function doImport(err) {
github oaeproject / Hilary / etc / migration / 12.1-to-12.2 / 2.tenant-email-domains.js View on Github external
* permissions and limitations under the License.
 */

/*
 * This migration script will copy each row's `emailDomain` value to `emailDomains`
 */

const path = require('path');
const _ = require('underscore');
const optimist = require('optimist');

const Cassandra = require('oae-util/lib/cassandra');
const log = require('oae-logger').logger('tenants-email-domains-migrator');
const OAE = require('oae-util/lib/oae');

const { argv } = optimist
  .usage('$0 [--config