How to use the posix-getopt.BasicParser function in posix-getopt

To help you get started, we’ve selected a few posix-getopt 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 Voxer / node-corevis / corevis.js View on Github external
'',
  'Options',
  '  -h, --help       print this message and exit',
  '  -l, --load   argument to pass to `::load` in mdb(1), defaults to "v8"',
  '  -u, --updates    check npm for available updates to this program',
  '  -v, --version    print the version number and exit',
].join('\n');

// command line arguments
var options = [
  'h(help)',
  'l:(load)',
  'u(updates)',
  'v(version)',
].join('');
var parser = new getopt.BasicParser(options, process.argv);

var option;
var opts = {
  load: 'v8',
};
while ((option = parser.getopt()) !== undefined) {
  switch (option.option) {
    case 'h': console.log(usage); process.exit(0);
    case 'l': opts.load = option.optarg; break;
    case 'u': // check for updates
      require('latest').checkupdate(package, function(ret, msg) {
        console.log(msg);
        process.exit(ret);
      });
      return;
    case 'v': console.log(package.version); process.exit(0);
github bahamas10 / hue-cli / hue-cli.js View on Github external
'  -j, --json             force output to be in json',
    '  -u, --updates          check for available updates',
    '  -v, --version          print the version number and exit'
  ].join('\n');
}

// command line arguments
var options = [
  'c:(config)',
  'h(help)',
  'H:(host)',
  'j(json)',
  'u(updates)',
  'v(version)'
].join('');
var parser = new getopt.BasicParser(options, process.argv);

var option;
var config = {};
var configfile;
var json = false;
while ((option = parser.getopt()) !== undefined) {
  switch (option.option) {
    case 'c': configfile = option.optarg; break;
    case 'h': console.log(usage()); process.exit(0);
    case 'H': config.host = option.optarg; break;
    case 'j': json = true; break;
    case 'u': // check for updates
      require('latest').checkupdate(package, function(ret, msg) {
        console.log(msg);
        process.exit(ret);
      });
github bahamas10 / node-manta-sync / manta-sync.js View on Github external
'  -v, --version             print the version number and exit'
  ].join('\n');
}

// command line arguments
var options = [
  'c:(concurrency)',
  'd(delete)',
  'h(help)',
  'j(just-delete)',
  'm(md5)',
  'n(dry-run)',
  'u(updates)',
  'v(version)'
].join('');
var parser = new getopt.BasicParser(options, process.argv);

var opts = {
  concurrency: 30,
  delete: false,
  dryrun: false,
  md5: false,
  justdelete: false,
};
var option;
while ((option = parser.getopt()) !== undefined) {
  switch (option.option) {
    case 'c': opts.concurrency = +option.optarg; break;
    case 'd': opts.delete = true; break;
    case 'h': console.log(usage()); process.exit(0);
    case 'j': opts.justdelete = true; break;
    case 'm': opts.md5 = true; break;
github toyokazu / internet-visualizer2 / scripts / capture_sender.js View on Github external
var mod_getopt = require('posix-getopt');
//var http = require('http');
var https = require('https');
var ip = require('ip');
var mmdbreader = require('maxmind-db-reader');
var spawn = require('child_process').spawn;
var util = require('util');
var io = require('socket.io-client');
var clients = require(path.resolve(__dirname, '../public/clients.json'));


// --- parse options ---
//
var parser, option;

parser = new mod_getopt.BasicParser('c:(interval)df:(filter)F:(file)g:(global URI)H:(host)hi:(interface)p:(port)r:(repeat)t:(tshark)', process.argv);

var usage = function() {
  console.log("usage: capture-sender.js [options]");
  console.log("options:");
  console.log(" [-c ]");
  console.log(" [-d]");
  console.log(" [-f 
github nhoss2 / nodewiki / nodewiki.js View on Github external
var connect = require("connect");
var socketio = require("socket.io");
var mod_getopt = require('posix-getopt');
var mdserver = require("./lib/mdserver");
var getDir = require("./lib/getDir");

// Defaults
var portNumberDefault = process.env.PORT || 8888;
var listenAddr = process.env.NW_ADDR || "";    // "" ==> INADDR_ANY
exports.gitMode = false;  // exported for lib/mdserver.js

var portNumber = portNumberDefault;

// Process command line
var parser, option;
parser = new mod_getopt.BasicParser('a:(addr)g(git)h(help)l(local)p:(port)', process.argv);

while ((option = parser.getopt()) !== undefined) {

  switch (option.option) {

  case 'a':
    listenAddr = option.optarg;
    break;

  case 'g':
    if (fs.existsSync(process.cwd() + '/.git')){
      exports.gitMode = true;
    } else {
      console.log(
        'ERROR: No git repository found\n',
        '\'--git\' requires a git repository in the current directory.\n',
github toyokazu / internet-visualizer2 / scripts / stream_server.js View on Github external
#!/usr/bin/env node
var mod_getopt = require('posix-getopt');
var http = require("http");
var socketio = require("socket.io");
var fs = require("fs");
var util = require("util");


// --- parse options ---
//
var parser, option;

parser = new mod_getopt.BasicParser('dH:(host)hp:(port)', process.argv);

var usage = function() {
  console.log("usage: capture-sender.js [options]");
  console.log("options:");
  console.log(" [-d]");
  console.log(" [-H ]");
  console.log(" [-h] show this message");
  console.log(" [-p ]");
};

// --- option parameters ---
//
var debug = false;
var host = null;
var port = '12345';
github jpenalbae / chita / chita.js View on Github external
//console.log(writes);
    fmt.genFmt(_opts.pos, writes, _opts.written);
}



/* Get the command and remove it */
var cmd = process.argv[2];
process.argv.splice(2, 1);
process.argc = process.argv.length;


/* Arguments parsing */
let option;
const parser = new mod_getopt.BasicParser('l:f:b:r:d:a:p:w:o:hxe', process.argv);
while ((option = parser.getopt()) !== undefined) {
    switch (option.option) {
    case 'l':
        _opts.len = option.optarg;
        break;

    case 'f':
        _opts.file = option.optarg;
        break;

    case 'r':
        _opts.chain = option.optarg;
        break;

    case 'b':
        _opts.base = option.optarg;
github joyent / manatee / backupserver.js View on Github external
function parseOptions() {
    var option;
    var opts = {};
    var parser = new getopt.BasicParser('vf:(file)', process.argv);

    while ((option = parser.getopt()) !== undefined) {
        switch (option.option) {
            case 'f':
                opts.file = option.optarg;
                break;

            case 'v':
                // Allows us to set -vvv -> this little hackery
                // just ensures that we're never < TRACE
                LOG_LEVEL_OVERRIDE = true;
                LOG.level(Math.max(bunyan.TRACE, (LOG.level() - 10)));
                if (LOG.level() <= bunyan.DEBUG)
                    LOG = LOG.child({src: true});
                break;
github joyent / manatee / sitter.js View on Github external
function parseOptions() {
    var option;
    var opts = {};
    var parser = new getopt.BasicParser('vf:(file)', process.argv);

    while ((option = parser.getopt()) !== undefined) {
        switch (option.option) {
            case 'f':
                opts.file = option.optarg;
                break;

            case 'v':
                // Allows us to set -vvv -> this little hackery
                // just ensures that we're never < TRACE
                LOG_LEVEL_OVERRIDE = true;
                LOG.level(Math.max(bunyan.TRACE, (LOG.level() - 10)));
                break;

            default:
                LOG.fatal('Unsupported option: ', option.option);
github joyent / manatee / snapshotter.js View on Github external
function parseOptions() {
    var option;
    var opts = {};
    var parser = new getopt.BasicParser('vf:(file)', process.argv);

    while ((option = parser.getopt()) !== undefined) {
        switch (option.option) {
            case 'f':
                opts.file = option.optarg;
                break;

            case 'v':
                // Allows us to set -vvv -> this little hackery
                // just ensures that we're never < TRACE
                LOG_LEVEL_OVERRIDE = true;
                LOG.level(Math.max(bunyan.TRACE, (LOG.level() - 10)));
                if (LOG.level() <= bunyan.DEBUG)
                    LOG = LOG.child({src: true});
                break;

posix-getopt

POSIX-style getopt()

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular posix-getopt functions

Similar packages