How to use the cli.args function in cli

To help you get started, we’ve selected a few cli 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 DefinitelyTyped / DefinitelyTyped / cli / cli-tests.ts View on Github external
// ========================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/cat.js
// ========================================================================

var output_file = function(file: string) {
    cli.withInput(file, function (line, sep, eof) {
        if (!eof) {
            cli.output(line + sep);
        } else if (cli.args.length) {
            output_file(cli.args.shift());
        }
    });
};

if (cli.args.length) {
    output_file(cli.args.shift());
}

// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/command.js
// ============================================================================

cli.parse(null, ['install', 'test', 'edit', 'remove', 'uninstall', 'ls']);

console.log('Command is: ' + cli.command);


// ============================================================================
// Example: https://github.com/node-js-libs/cli/blob/master/examples/echo.js
// ============================================================================
github mrvautin / githubdocs / githubdocs.js View on Github external
const config = require('./config/config.json');
const cli = require('cli');
var shared = require('./shared');

// parse args
let args = cli.args;
if(args.length > 0){
    args = args[0];
}

// Build docs
if(args === 'build'){
    shared.build(function(){
        console.log("[INFO] Successfully built");
        process.exit(0);
    });
}else if(args === 'serve'){
    require("./server")
}else{
    console.log("[ERROR] No option selected. Valid options are: build, serve");
}
github jamesshore / automatopia / node_modules / jshint / src / cli.js View on Github external
// This is a hack. exports.run is both sync and async function
    // because I needed stdin support (and cli.withStdin is async)
    // and was too lazy to change tests.

    function done(passed) {
      /*jshint eqnull:true */

      if (passed == null)
        return;

      exports.exit(passed ? 0 : 2);
    }

    done(exports.run({
      args:       cli.args,
      config:     config,
      reporter:   reporter,
      ignores:    loadIgnores({exclude: options.exclude, excludePath: options["exclude-path"]}),
      extensions: options["extra-ext"],
      verbose:    options.verbose,
      extract:    options.extract,
      filename:   options.filename,
      useStdin:   {"-": true, "/dev/stdin": true}[args[args.length - 1]]
    }, done));
  }
};
github victorporof / Sublime-JSHint / scripts / node_modules / jshint / src / cli.js View on Github external
// This is a hack. exports.run is both sync and async function
    // because I needed stdin support (and cli.withStdin is async)
    // and was too lazy to change tests.

    function done(passed) {
      /*jshint eqnull:true */

      if (passed == null)
        return;

      exports.exit(passed ? 0 : 2);
    }

    done(exports.run({
      args:       cli.args,
      config:     config,
      reporter:   reporter,
      ignores:    loadIgnores({ exclude: options.exclude, excludePath: options["exclude-path"] }),
      extensions: options["extra-ext"],
      verbose:    options.verbose,
      extract:    options.extract,
      filename:   options.filename,
      prereq:     options.prereq,
      useStdin:   { "-": true, "/dev/stdin": true }[args[args.length - 1]]
    }, done));
  }
};
github theycallmeswift / node-mongodb-s3-backup / bin / mongodb_s3_backup.js View on Github external
cli
  .enable('version')
  .setApp(pkg.name, pkg.version)
  .setUsage(cli.app + ' [OPTIONS] 
github jamesshore / lets_code_javascript / node_modules / jshint / src / cli.js View on Github external
// This is a hack. exports.run is both sync and async function
    // because I needed stdin support (and cli.withStdin is async)
    // and was too lazy to change tests.

    function done(passed) {
      /*jshint eqnull:true */

      if (passed == null)
        return;

      exports.exit(passed ? 0 : 2);
    }

    done(exports.run({
      args:       cli.args,
      config:     config,
      reporter:   reporter,
      ignores:    loadIgnores({ exclude: options.exclude, excludePath: options["exclude-path"] }),
      extensions: options["extra-ext"],
      verbose:    options.verbose,
      extract:    options.extract,
      filename:   options.filename,
      prereq:     options.prereq,
      useStdin:   { "-": true, "/dev/stdin": true }[args[args.length - 1]]
    }, done));
  }
};
github voloko / uki / tools / tools.js View on Github external
var fs = require('fs'),
        path = require('path');
        
    try {
        require(path.join(process.cwd(), 'express.js')).init(dev_server.app);
        util.puts("Loaded express.js");
    } catch(e) {}
    
    dev_server.init();
    dev_server.app.listen(port, host);
    util.puts("Server at http://" + (host || "127.0.0.1") + ":" + port.toString() + "/");
    
} else if (cli.command == 'build') {
    
    var static_require = require('./static_require');
    var file = cli.args[0];
    var options = { filePath: cli.args[0], squeeze: cli.options.squeeze };
    var code = static_require.require(options);
    console.log(code);
}
github michaelgwelch / migrate-issues / pushIssues.js View on Github external
var fs = require('fs');
var _ = require('lodash');
var async = require('async');
var moment = require('moment');
var cli = require('cli');

cli.parse();

var owner = 'secui';

if(!cli.args[0]) {
	console.log('node pushIssues.js repoName');
	return;
}

var repo = cli.args[0];

var dest = {
	options: {
		url: "https://c201sa26.jci.com/api/v3"
	},
	token: "af58f10c5bef7dbdcf812ccb2c848b2dcef5d383",
	repo: owner + '/' + repo,
	ca: require('fs').readFileSync('/Users/mgwelch/DropBox/JCI Root CA.pem')

};
var destApiUrl = (dest.options && dest.options.url) || "https://api.github.com";
var destRepoUrl = destApiUrl + '/repos/' + dest.repo;
var destHeaders = {
	'Authorization': 'token ' + dest.token,
	'user-agent': 'node.js'	
};
github smfoote / tornado / bin / tornado.es6 View on Github external
});
}


function compile(data, name) {
  var compiled;

  try {
    compiled = compiler.compile(parser.parse(data), name);
  } catch (e) {
    return cli.fatal('[' + name + '] ' + e);
  }
  return compiled;
}

let paths = glob(cli.args);

handle();