How to use the optimist.argv.h 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 mandulaj / PiDashboard / server.js View on Github external
function setup() {
  'use strict';

  // Check OS (We only work on raspberry)
  if (os.type() != "Linux") {
    console.error("You are not running Linux. Exiting ... \n".red);
    // TODO: uncomment this at the end
    //process.exit(0);
  }

  process.title = 'PiDashboard.js';

  // Help display
  if (optimist.help || optimist.h) {
    require('./lib/help_log.js');
    process.exit(0);
  }

  var cert = "", // Path to cert and key
    key = "";
  // Prepare keys and certs if we run https
  if (optimist.cert || optimist.key || config.forceSSL) {
    config.forceSSL = true;



    if (optimist.cert) cert = optimist.cert; // If provided from cmd
    if (optimist.key) key = optimist.key;

    if (!cert.length) cert = config.paths.cert; //else grab the default
github colorhook / node-smushit / cli.js View on Github external
},
	report: function () {
		
	},
	version: function () {
		util.puts('smushit v0.3.0');
	}
};

function respond (type) {
	responses[type].call();
}

var argv = require('optimist').argv;

if (argv.help || argv.h) {
	respond('help');
} else if (argv.version) {
	respond('version');
} else if (argv.c || argv.config){
	var s = argv.c || argv.config;
	
	if(s === true){
		persist.each(function(key, value){
			console.log(' smushit config: %s = %s ', key, value);
		});
		return;
	}
	s = s.split('=');
	var	key = s[0],
		value = s[1];
github Hacklone / private-bower / lib / main.js View on Github external
function _start(configPath) {
        if(argv.h || argv.help) {
            logger.logHelp();

            utils.process.exit();
        }
        if (argv.version) {
            console.log(version);
            utils.process.exit();
        }

        _handleErrors();
        _handleShutDown();

        var serverApp = Express();
        
        var defaultConfigPath = path.join(utils.dirname, '../bower.conf.json');
        configurationManager.loadConfiguration(configPath || argv.config || defaultConfigPath);
github dominictarr / crdt / example / socket.io / bundle.js View on Github external
es.pipeable = function () {
  if(process.title != 'node')
    return console.error('cannot use es.pipeable in the browser')
  //(require) inside brackets to fool browserify, because this does not make sense in the browser.
  var opts = (require)('optimist').argv
  var args = [].slice.call(arguments)
  
  if(opts.h || opts.help) {
    var name = process.argv[1]
    console.error([
      'Usage:',
      '',
      'node ' + name + ' [options]',
      '  --port PORT        turn this stream into a server',
      '  --host HOST        host of server (localhost is default)',
      '  --protocol         protocol http|net will require(protocol).createServer(...',
      '  --help             display this message',
      '',
      ' if --port is not set, will stream input from stdin',
      '',
      'also, pipe from or to files:',
      '',
      ' node '+name+ ' < file    #pipe from file into this stream',
      ' node '+name+ ' < infile > outfile    #pipe from file into this stream',
github monaca / monaca-cli / src / monaca.js View on Github external
lib.printHelp(taskList, extended);
      process.exit(0);
    }

    var task = this._getTask();

    if (!task.set) {
      util.fail('Error: ' + task.name + ' is not a valid task. Run `monaca --help` to show all available tasks.');
    }

    if (!terminal.isValidTask(task.name)) {
      util.fail(terminal.getInvalidCommandErrorMessage(task.name));
      process.exit(0);
    }

    if (argv.help || argv.h
      || (task.name === 'create' && argv._.length < 2 && !argv['template-list'])
      || (task.name === 'docs' && argv._.length < 2)
      || (task.name === 'remote build' && !argv.browser && !argv['build-list'] && argv._.length < 3)
      || (task.name === 'config' && !argv.reset && argv._.length < 2)
      || (task.name === 'signing' && !argv.reset && argv._.length < 2)
      )
    {
      util.displayHelp(task.name, taskList[task.set]);
      process.exit(0);
    }

    var runner = function(task) {
      var result = (require(path.join(__dirname, task.set))).run(task.name, info);
      Promise.resolve(result).then(function(result) {
        if (result && result.nextTask) {
          runner(result.nextTask);
github FabricLabs / fabric / scripts / reskindex.js View on Github external
#!/usr/bin/env node

var fs = require('fs');
var path = require('path');
var glob = require('glob');

var args = require('optimist').argv;

var header = args.h || args.header;

var componentsDir = path.join('src', 'components');

var componentIndex = path.join('src', 'component-index.js');

var packageJson = JSON.parse(fs.readFileSync('./package.json'));

var strm = fs.createWriteStream(componentIndex);

if (header) {
   strm.write(fs.readFileSync(header));
   strm.write('\n');
}

strm.write("/*\n");
strm.write(" * THIS FILE IS AUTO-GENERATED\n");