How to use the commander.port function in commander

To help you get started, we’ve selected a few commander 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 robohydra / robohydra / bin / robohydra.js View on Github external
sslOptions: fileConfig.sslOptions,
                quiet: commander.quiet || fileConfig.quiet
            },
            extraVars
        );
    } catch (e) {
        if (e.code === 'ENOENT') {
            console.error("Cannot read file '" + e.path + "'.");
        } else {
            // TODO: This needs to improve
            throw e;
        }
        process.exit(1);
    }

    var port = commander.port || fileConfig.port || 3000;
    server.on('error', function (e) {
        if (e.code === 'EADDRINUSE') {
            console.error("Couldn't listen in port " + port + ", aborting.");
        }
    });
    server.listen(port, function() {
        if (commander.quiet) {
            return;
        }
        var protocol = fileConfig.secure ? "https" : "http";
        var adminUrl = protocol + "://localhost:" + port + "/robohydra-admin";
        console.log("RoboHydra ready on port %d - Admin URL: %s",
                    port, adminUrl);
    });
}());
github Kitware / simput / bin / simput-cli.js View on Github external
shell.mkdir('-p', path.dirname(destination));
          shell.cp(source, destination);
        });
      }

      // Model --------------------------------
      fs.writeFileSync(
        path.join(program.output, 'model.json'),
        JSON.stringify(req.body.model, null, '    ')
      );

      // Return --------------------------------
      res.send('Data saved');
    });

  app.listen(program.port);
  console.log('Simput listening on port', program.port);

  if (!program.silent) {
    open(`http://localhost:${program.port}`);
  }
} else if (program.add) {
  simputManager.add(program.add);
} else if (program.list) {
  simputManager.list();
} else if (program.remove) {
  simputManager.remove(program.remove);
}
github olalonde / proof-of-assets / cli.js View on Github external
.action(function (file) {
    var obj = JSON.parse(fs.readFileSync(file));

    if (!baproof.verifySignatures(obj)) {
      console.error('INVALID signature found!');
      process.exit(-1);
    }

    var client = new bitcoin.Client({
      host: program.host,
      port: program.port,
      user: program.user,
      pass: program.pass
    });

    var total = 0;
    var addresses = baproof.getAddresses(obj);

    async.each(addresses, function (addr, cb) {
      client.cmd('getreceivedbyaddress', addr, function (err, res) {
        if (err) return console.error(err);
        total += Number(res);
        cb();
      });
    }, function (err) {
      if (err) {
        console.error(err);
github xcatliu / pagic / bin / pagic-build.js View on Github external
.option('-s, --serve', 'serve public dir')
  .option('-p, --port', 'override default port')
  .parse(process.argv);

const pagic = new Pagic();

if (program.watch) {
  pagic.watch().build();
} else {
  pagic.build();
}

if (program.serve) {
  let port = DEFAULT_PORT;
  if (program.port) {
    port = program.port;
  }

  http.createServer(
    ecstatic({ root: pagic.config.public_dir })
  ).listen(port);

  console.log(`Serve ${pagic.config.public_dir} on http://localhost:${port}/`);
}
github sourcegraph / javascript-typescript-langserver / src / build-server.ts View on Github external
}
}

process.on('uncaughtException', (err) => {
    console.error(err);
});

const defaultBuildPort = 2088;

program
    .version('0.0.1')
    .option('-s, --strict', 'Strict mode')
    .option('-p, --port [port]', 'LSP port (' + defaultBuildPort + ')', parseInt)
    .parse(process.argv);

const lspPort = program.port || defaultBuildPort;

console.error('Build server: listening for incoming LSP connections on', lspPort);

server.listen(lspPort);
github mongo-express / mongo-express / app.js View on Github external
}

  config.useBasicAuth = false;
}

if (commander.url) {
  config.mongodb.connectionString = commander.url;
  if (commander.admin) {
    config.mongodb.admin = true;
  }
}

config.mongodb.server = commander.host || config.mongodb.server;
config.mongodb.port = commander.dbport || config.mongodb.port;

config.site.port = commander.port || config.site.port;

if (!config.site.baseUrl) {
  console.error('Please specify a baseUrl in your config. Using "/" for now.');
  config.site.baseUrl = '/';
}

app.use(config.site.baseUrl, middleware(config));
app.use(config.site.baseUrl, csrf());

if (config.site.sslEnabled) {
  defaultPort     = 443;
  sslOptions  = {
    key:  fs.readFileSync(config.site.sslKey),
    cert: fs.readFileSync(config.site.sslCert),
  };
  server = https.createServer(sslOptions, app);
github kavanagh / srvlr / index.js View on Github external
var url = 'http://' + program.address + ':' + p.toString() + '/' + (program.url || '');
  if (program.open) {
    verbose('Opening browser...');
    !program.log && console.log(pkg.name + ' running at %s', url);
    opener(url);
  }
}

if (!program.port) {
  portfinder.basePort = defaults.basePort;
  portfinder.getPort(function (err, port) {
      if (err) throw err;
      listen(port);
  });
} else {
  listen(program.port);
}
github ShiftNrg / shift / app.js View on Github external
}, 60000);
}

program
	.version(packageJson.version)
	.option('-c, --config 
github xtremespb / taracotjs / bin / install-system.js View on Github external
function(callback) {
            if (program.silent || program.port) return callback();
            program.confirm('Do you wish to specify TaracotJS internal server port? ', function(ok) {
                if (ok) {
                    var set_port = '3000';
                    program.prompt('\nPort [3000]: ', function(_port) {
                        if (_port) set_port = _port;
                        port = set_port;
                        console.log("\nTaracotJS internal server port is now: " + port + "\n");
                        return callback();
                    });
                } else {
                    callback();
                }
            });
        },
        function(callback) {
github wuchangming / spy-debugger / src / index.js View on Github external
const weinreDelegate = require('./weinre/weinreDelegate')
const colors = require('colors')
const http = require('http')

program
    .version(require('../package.json').version)
    .option('-p, --port [value]', 'start port')
    .option('-i, --showIframe [value]', 'spy iframe window')
    .option('-b, --autoDetectBrowser [value]', 'Auto detect Browser Request')
    .option('-e, --externalProxy [value]', 'set external Proxy')
    .option('-c, --cache [value]', 'set no cache')
    .option('-w, --contentEditable [value]', 'set content editable')

program.parse(process.argv)

var cusSpyProxyPort = program.port || 9888

var cusShowIframe = false
if (program.showIframe === 'true') {
    cusShowIframe = true
}

var autoDetectBrowser = true
if (program.autoDetectBrowser === 'false') {
    autoDetectBrowser = false
}

var cusCache = false
if (program.cache === 'true') {
    cusCache = true
}