How to use the optimist.help 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 appcelerator / titanium / tests / run.js View on Github external
desc: 'disables colors'
	});

if (optimist.argv.hasOwnProperty('colors') && !optimist.argv.colors) {
	Base.useColors = false;
	colors.mode = 'none';
}

if (!process.env.APPC_COV) {
	console.log('Unit Test Tool'.cyan.bold + ' - Copyright (c) 2012-' + (new Date).getFullYear() + ', Appcelerator, Inc.  All Rights Reserved.');
}

// display the help, if needed
if (optimist.argv.help || optimist.argv.h) {
	console.log('\nUsage: ' + 'forge test [] [options]'.cyan + '\n');
	console.log(optimist.help());
	process.exit(0);
}

// load the config, if specified
global.conf = {};
var confFile = optimist.argv.conf || optimist.argv.c;
if (confFile) {
	if (!fs.existsSync(confFile = path.resolve(confFile))) {
		console.error(('\nERROR: Config file "' + confFile + '" does not exist').red + '\n');
		process.exit(1);
	}

	try {
		global.conf = JSON.parse(fs.readFileSync(confFile));
	} catch (ex) {
		console.error(('\nERROR: Unable to parse config file "' + confFile).red + '"\n');
github gkoberger / omnium / builder.js View on Github external
function main(folder, args) {
    folder = (folder || "").replace(/^[\/\\]+|[\/\\]+$/, "");
    if (!folder) {
        console.log(Optimist.help());
        process.exit(1);
    }

    // Load settings file
    var settings = JSON.parse(Fs.readFileSync(Path.join(__dirname, folder, "build.json")));
    settings.folder = folder;
    settings.minifyJS = args["minify-js"];
    settings.combineJS = args["combine-js"];
    settings.openInBrowser = args.open;

    // Remove the output.
    rmTree(Path.join(__dirname, folder, "output"));

    // We may not want to do this...
    rmTree(Path.join(__dirname, ".builder", "jetpack-sdk", "_" + folder));
github karma-runner / karma / lib / cli.js View on Github external
function processArgs (argv, options, fs, path) {
  if (argv.help) {
    console.log(optimist.help())
    process.exit(0)
  }

  if (argv.version) {
    console.log(`Karma version: ${constant.VERSION}`)
    process.exit(0)
  }

  // TODO(vojta): warn/throw when unknown argument (probably mispelled)
  Object.getOwnPropertyNames(argv).forEach(function (name) {
    let argumentValue = argv[name]
    if (name !== '_' && name !== '$0') {
      assert(!name.includes('_'), `Bad argument: ${name} did you mean ${name.replace('_', '-')}`)

      if (Array.isArray(argumentValue)) {
        argumentValue = argumentValue.pop() // If the same argument is defined multiple times, override.
github BryanDonovan / node-simple-elasticsearch / test / run.js View on Github external
if (argv.bail) {
    mocha.bail();
}

var valid_test_types = ['unit', 'functional', 'acceptance', 'integration'];
var requested_types = argv.types.split(',');
var types_to_use = [];

valid_test_types.forEach(function (valid_test_type) {
    if (requested_types.indexOf(valid_test_type) !== -1) {
        types_to_use.push(valid_test_type);
    }
});

if (argv.help || types_to_use.length === 0) {
    console.log('\n' + optimist.help());
    process.exit();
}

var is_valid_file = function (file) {
    for (var i = 0; i < types_to_use.length; i++) {
        var test_type = types_to_use[i];
        var ext = test_type + ".js";

        if (file.indexOf(ext) !== -1) {
            return true;
        }
    }

    return false;
};
github RemoteDebug / remotedebug-ios-webkit-adapter / src / index.ts View on Github external
process.title = 'remotedebug-ios-webkit-adapter';

let argv = optimist
  .usage('Usage: $0 -p [num]')
  .alias('p', 'port').describe('p', 'the adapter listerning post').default('p', 9000)
  .describe('version', 'prints current version').boolean('boolean')
  .argv;

if (argv.version) {
  console.error(info.version);
  process.exit(0);
}

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

const server = new ProxyServer();

server.run(argv.port).then(port => {
  console.log(`remotedebug-ios-webkit-adapter is listening on port ${port}`);
}).catch(err => {
  console.error('remotedebug-ios-webkit-adapter failed to run with the following error:', err)
  process.exit();
})

process.on('SIGINT', function () {
  server.stop();
  process.exit();
});
github azproduction / lmd / bin / lmd_actions / server.js View on Github external
var help = [
        'Usage:'.bold.white.underline,
        '',

        '  lmd server ' + ''.blue + ' [' + ''.yellow + ']',
        '',

        'Example:'.bold.white.underline,
        '',

        '  lmd server ' + 'development'.blue,
        '  lmd server ' + 'development'.blue + ' --a localhost --p 8080'.yellow,
        ''
    ];

    var options = optimist.help().split('\n');
    options.unshift(options[0].bold.white.underline);
    options[1] = '';

    help = help.concat(options);

    cli.help(help, errorMessage);
}
github sweet-js / sweet-core / browser / scripts / sjs.js View on Github external
var sourcemap = argv.sourcemap;
    var noparse = argv['no-parse'];
    var numexpands = argv['num-expands'];
    var displayHygiene = argv['step-hygiene'];
    var readableNames = argv['readable-names'];
    var formatIndent = parseInt(argv['format-indent'], 10);
    if (formatIndent !== formatIndent) {
        formatIndent = 4;
    }
    var file;
    if (infile) {
        file = fs.readFileSync(infile, 'utf8');
    } else if (argv.stdin) {
        file = fs.readFileSync('/dev/stdin', 'utf8');
    } else if (argv._.length === 0) {
        console.log(require('optimist').help());
        return;
    }
    var cwd = process.cwd();
    var modules = typeof argv.module === 'string' ? [argv.module] : argv.module;
    modules = (modules || []).map(function (path$2) {
        return sweet.loadNodeModule(cwd, path$2);
    });
    var options = {
            filename: infile,
            modules: modules,
            ast: ast,
            readableNames: readableNames,
            escodegen: { format: { indent: { style: Array(formatIndent + 1).join(' ') } } }
        };
    if (watch && outfile) {
        fs.watch(infile, function () {
github jlongster / macro-editor / sweetjs / src / sjs.js View on Github external
var noparse = argv['no-parse'];
    var numexpands = argv['num-expands'];
    var displayHygiene = argv['step-hygiene'];
    var readableNames = argv['readable-names'];
    var formatIndent = parseInt(argv['format-indent'], 10);
    if (formatIndent !== formatIndent) {
        formatIndent = 4;
    }

    var file;
    if (infile) {
        file = fs.readFileSync(infile, "utf8");
    } else if (argv.stdin) {
        file = fs.readFileSync("/dev/stdin", "utf8");
    } else if (argv._.length === 0) {
        console.log(require("optimist").help());
        return;
    }


    var cwd = process.cwd();
    var modules = typeof argv.module === 'string' ? [argv.module] : argv.module;

    modules = (modules || []).map(function(path) {
        return sweet.loadNodeModule(cwd, path);
    });

    var options = {
        filename: infile,
        modules: modules,
        ast: ast,
        readableNames: readableNames,
github braintree / mallorca / lib / command-line-arguments.js View on Github external
function validate(args) {
  if (args.help) {
    throw new Error(optimist.help());
  }

  if (args.upstreamURL == null || typeof args.upstreamURL === 'undefined') {
    throw new Error(optimist.help() + 'Must provide UPSTREAM_HOST_OR_URL\n');
  } else if (!args.upstreamURL.protocol.match(/^https?:$/)) {
    throw new Error(optimist.help() + 'UPSTREAM_HOST_OR_URL must be host name or a valid http/https URL');
  }
}
github CreateJS / TweenJS / build / build.js View on Github external
function displayUsage()
{
	print(setColorText(OPTIMIST.help(), "yellow"));
}