How to use the optimist.argv._ 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 apache / cordova-docs / tools / bin / toc.js View on Github external
function main () {

    var docsRoot = argv._[0];
    var tocRoot = argv._[1];

    // validate args
    if ((!docsRoot) || (!tocRoot)) {
        var scriptName = path.basename(process.argv[1]);
        console.log('usage: ' + scriptName + ' docsRoot tocRoot');
        console.log(scriptName + ': error: too few arguments');
        return 1;
    }

    // go through all the languages
    util.listdirsSync(docsRoot).forEach(function (languageName) {
        var languagePath = path.join(docsRoot, languageName);

        // go through all the versions
        util.listdirsSync(languagePath).forEach(function (versionName) {
            var versionPath = path.join(languagePath, versionName);
github shawnbot / d3-to-png / index.js View on Github external
var fs = require("fs"),
    sys = require("sys"),
    jsdom = require("jsdom"),
    argv = require("optimist").argv,
    scripts = [
        "vendor/d3.v3.min.js"
    ],
    // I'm sure there's a much better way to do this...
    render = require("./" + argv._[0]),
    // just write to stdout
    write = sys.puts;

// create a jsdom environment with an empty <svg> document
jsdom.env("<svg></svg>", scripts, function(errors, window) {
    render(window, argv, function(error, node) {
      // check to see if this is a d3 selection, and if so get the DOM node
      if (node instanceof window.d3.selection) {
        node = node.node();
      }
      // set the xmlns attribute on the root node
      node.setAttribute("xmlns", "http://www.w3.org/2000/svg");
      // write the XML declaration first
      write('');
      // then "serialize" using outerHTML
      write(node.outerHTML);</svg>
github hyperflow-wms / hyperflow / scripts / dax_convert.js View on Github external
var PegasusConverter = require('../converters/pegasus_dax.js'),
    argv = require('optimist').argv;

var pc = new PegasusConverter();

if (!argv._[0]) {
	console.log("Usage: node dax_convert.js ");
	process.exit();
}

pc.convertFromFile(argv._[0], function(err, wfOut) {
	console.log(JSON.stringify(wfOut, null, 2));
});
github oortcloud / meteorite / bin / meteorite.js View on Github external
#!/usr/bin/env node

var Project = require('../lib/project');
var Runner = require('../lib/runner');
var argv = require('optimist').argv;

var showUsage = function() {
  console.log('show usage');
  process.exit();
};

var showHome = function() {
};

var command = argv._[0] || 'run';

switch(command) {

  case 'run':
    new Project().run(function(project) {
      console.log('Project running!');
      
    });
    break;

  case 'install':
    new Project().install(function() {
      console.log('Project installed!');
    });
    break;
github ttrace / Our-Sphere / client / build / check.js View on Github external
#!/usr/bin/env node

var argv = require('optimist').argv,
    jshint = require("./jshint").JSHINT,
    src;

if (argv.h || argv.help) {
  console.log('Usage: check.js \n or check.js &lt; <input>');
  process.exit(0);
}

if (argv._[0]) {
  var path = argv._[0];
  src = require("fs").readFileSync(path, 'utf8');
  check(src);
} else {
  var stdin = process.openStdin();
  stdin.setEncoding('utf-8');
  stdin.on('data', function(chunk) {src += chunk;});
  stdin.on('end', function() {check(src);});
}

function check(text) {

  var	config = {
    evil: true,
    browser: true,
    wsh: true,
    eqnull: true,
github antiboredom / servi-ide / app / node_modules / servi / node_modules / handlebars / node_modules / optimist / example / nonopt.js View on Github external
#!/usr/bin/env node
var argv = require('optimist').argv;
console.log('(%d,%d)', argv.x, argv.y);
console.log(argv._);
github monaca / monaca-cli / src / config.js View on Github external
ConfigTask.run = function(taskName, info) {
  monaca = new Monaca(info);
  var command = argv._[1];

    var params = {};

   ['reset']
  .forEach(function(property) {
    if (argv.hasOwnProperty(property)) {
      params[property] = argv[property];
    }
  });

  if (taskName === 'config' && command === 'proxy') {
    if (argv._[2] && !Object.keys(params).length) {
      this.setProxy(argv._[2]);
    } else if (!argv._[2] && params.reset) {
      this.removeProxy();
    } else {
github jondubois / nombo / samples / memo / server.node.js View on Github external
var argv = require('optimist').argv;
var port = argv._[0] ? argv._[0] : 8000;
var release = argv.hasOwnProperty('r');
var Master = require('nombo').Master;

var options = {
	port: port,
	release: release,
	sessionTimeout: 10,
	workers: [{port: 9022}],
	stores: [{port: 9020}, {port: 9021}],
	title: 'Memo App'
};

var nombo = new Master(options);
nombo.start();