hardlounge/src/command-line/start.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

var ClientManager = new require("../clientManager");
var program = require("commander");
var shout = require("../server");
var Helper = require("../helper");
program
2014-09-15 19:50:57 +00:00
.option("-H, --host <ip>", "host")
2014-09-09 20:06:26 +00:00
.option("-p, --port <port>", "port")
2014-10-11 06:17:41 +00:00
.option("-B, --bind <ip>", "bind")
2014-09-15 19:50:57 +00:00
.option(" --public", "mode")
.option(" --private", "mode")
.command("start")
.description("Start the server")
.action(function() {
var users = new ClientManager().getUsers();
2014-10-03 23:33:44 +00:00
var config = Helper.getConfig();
var mode = config.public;
if (program.public) {
mode = true;
} else if (program.private) {
mode = false;
}
if (!mode && !users.length) {
console.log("");
console.log("No users found!");
2014-09-13 17:16:07 +00:00
console.log("Create a new user with 'shout add <name>'.");
console.log("");
} else {
var host = program.host || process.env.IP || config.host;
var port = program.port || process.env.PORT || config.port;
2014-10-11 06:17:41 +00:00
var bind = program.bind || process.env.BIND || config.bind;
shout(port, host, mode, bind);
}
});