How to use the optimist.showHelp 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 gameclosure / devkit / src / init / index.js View on Github external
var common = require('../common');
var register = require('../register').register;

/**
 * Command line.
 */

var argv = require('optimist')
	.usage('basil init [project-dir]')
	.describe('help', 'Show options.').alias('help', 'h').boolean('help')
	.describe('template', 'Pick a template to start building your game').alias('template', 't')
	.argv;

if (argv.help) {
	require('optimist').showHelp();
	process.exit(0);
}

function createUUID (a) {
	return a
				? (a ^ Math.random() * 16 >> a / 4).toString(16)
					: ([1e7]+1e3+4e3+8e3+1e11).replace(/[018]/g, createUUID);
}

//initialise an empty repo
exports.init = function(args, cb) {
	// basil init
	// basil init ./cake

	if (!args[0]) {
		console.log('Usage: basil init [folder path]');
github webinos / Webinos-Platform / webinos_pzp.js View on Github external
},
        "enforceWidgetCSP":{
            describe:"enforce content security policy on the widgets",
            default :false
        },
        "test":{
            describe:"start the PZP and exit if it loaded successfully.  Useful for testing the build",
            default :false
        },
        "help"            :{
            describe:"to get this help menu"
        }})
    .argv;

if (argv.help) {
    require ('optimist').showHelp ();
    process.exit ();
}
if (argv.policyEditor) {
    __EnablePolicyEditor = true;
}

require ("fs").readFile (require ("path").join (__dirname, "config-pzp.json"), function (err, data) {
    var config = {};
    if (!err) {
        config = JSON.parse (data);
    }

    // overwrite config file options with cli options
    config = require ('./webinos/core/util/lib/helpers').extend (config, argv);

    if (config.pzhName !== "") {
github julianbrowne / graffeine / server / node_modules / node-static / bin / cli.js View on Github external
var d = new Date();
        var seconds = d.getSeconds() < 10? '0'+d.getSeconds() : d.getSeconds(),
            datestr = d.getHours() + ':' + d.getMinutes() + ':' + seconds,
            line = datestr + ' [' + response.statusCode + ']: ' + request.url,
            colorized = line;
        if (tty.isatty(process.stdout.fd))
            colorized = (response.statusCode >= 500) ? line.red.bold :
                        (response.statusCode >= 400) ? line.red :
                        line;
        console.log(colorized);
    };

    var file, options;

if (argv.help){
    require('optimist').showHelp(console.log);
    process.exit(0);
}

if (argv.version){
    console.log('node-static', statik.version.join('.'));
    process.exit(0);
}

if (argv.cache){
    (options = options || {}).cache = argv.cache;
}

if (argv.headers){
    (options = options || {}).headers = JSON.parse(argv.headers);
}
github indutny / vock / lib / vock / cli / main.js View on Github external
});

  this.instance.on('dht:save', function (config) {
    nconf.set('dht', config);
    nconf.save();
  });

  this.initKeyboard();

  if (this.cmd === 'create') {
    return this.handleConnect();
  } else if (this.cmd === 'connect' && this.argv._[1]) {
    return this.handleConnect();
  }

  require('optimist').showHelp();
  process.exit(0);
};
github db-migrate / node-db-migrate / lib / commands / create-migration.js View on Github external
async function executeCreateMigration (internals, config) {
  let migrationsDir = internals.argv['migrations-dir'];
  let folder, path;

  internals.runTimestamp = new Date();

  if (internals.migrationMode && internals.migrationMode !== 'all') {
    migrationsDir =
      internals.argv['migrations-dir'] + '/' + internals.migrationMode;
  }

  if (internals.argv._.length === 0) {
    log.error("'migrationName' is required.");
    if (!internals.isModule) {
      optimist.showHelp();
    }

    throw new Error("'migrationName' is required.");
  }

  try {
    await createMigrationDir(migrationsDir);
  } catch (err) {
    log.error('Failed to create migration directory at ', migrationsDir, err);
    throw new Error('Failed to create migration directory.');
  }

  const Migration = require('../template.js');

  internals.argv.title = internals.argv._.shift();
  folder = internals.argv.title.split('/');
github piuccio / node-coverage / instrument.js View on Github external
fileSystem.statFileOrFolder([source], "", callback, {
			"function" : options["function"],
			"condition" : options["condition"],
			"submit" : options["submit"],
			"staticInfo": !staticInfo,
			"exclude" : options.exclude,
			"ignore" : options.ignore,
			"verbose" : options.verbose
		}, staticInfo);

		if (staticInfo) {
			fs.writeFileSync(staticInfoFile, JSON.stringify(staticInfo));
		}
	} catch (ex) {
		require("optimist").showHelp();
		return console.error(ex);
	}
};
github wzrdtales / node-ultimate-migrate / index.js View on Github external
loadConfig();

        if( folder.length < 1 )
        {
            log.info( 'Please enter a valid command, i.e. db:create|db:drop' );
        }
        else
        {
            global.mode = folder[ 1 ];
            executeDB();
        }
        break;

    default:
        log.error( 'Invalid Action: Must be [up|down|create].' );
        optimist.showHelp();
        process.exit( 1 );
        break;
    }
}
github gameclosure / devkit / src / update / update.js View on Github external
var ff = require('ff');
var Version = require('../shared/Version');

var argv = require('optimist')
	.usage('basil update [options]')
	.describe('tag', 'Update to a specific tag.').alias('tag', 't')
	.describe('channel', 'Specify a channel (e.g "beta").').alias('channel', 'c').default('channel', 'release')
	.describe('list-channel', 'List possible channels.').alias('list-channel', 'l').default('list-channel', false)
	.describe('list-version', 'List possible channels.').alias('list-version', 'v').default('list-version', false)
	.describe('reapply-changes', 'Stash and reapply your changes.').alias('reapply-changes', 'r').default('reapply-changes', false)
	.describe('help', 'Show options.').alias('help', 'h').default('help', false)
	.argv;


if (argv.help) {
	require('optimist').showHelp();
	process.exit(2);
}

if (argv['list-channel']) {
	common.child('git', ['tag', '-l'], {cwd: common.paths.root(), silent: true}, function (code, data) {
		data = String(data).split('\n');
		var tags = {};
		for (var i in data) {
			var match = data[i].match(/-(.*)-/);
			
			if (match && !(match[1] in tags)) {
				tags[match[1]] = true;
			}
		}
		
		for (i in tags) {
github gameclosure / devkit / src / commands / help.js View on Github external
this.exec = function (command, args, cb) {
    var cmd = args.shift();

    if (commands.has(cmd)) {
      commands.get(cmd).showHelp(args);
    } else {
      require('optimist').showHelp();
    }

    cb && cb();
  }
});