hardlounge/src/command-line/start.js

35 lines
977 B
JavaScript
Raw Normal View History

var ClientManager = new require("../clientManager");
var program = require("commander");
var server = require("../server");
var Helper = require("../helper");
program
2014-10-11 08:35:28 -04:00
.option("-H, --host <ip>" , "host")
.option("-P, --port <port>" , "port")
.option("-B, --bind <ip>" , "bind")
.option(" --public" , "mode")
.option(" --private" , "mode")
.command("start")
.description("Start the server")
.action(function() {
var users = new ClientManager().getUsers();
2014-10-03 19:33:44 -04:00
var config = Helper.getConfig();
var mode = config.public;
if (program.public) {
mode = true;
} else if (program.private) {
mode = false;
}
if (!mode && !users.length) {
2016-04-16 07:32:38 -04:00
log.warn("No users found!");
log.info("Create a new user with 'lounge add <name>'.");
} else {
server({
2014-10-14 14:47:49 -04:00
host: program.host || process.env.IP || config.host,
port: program.port || process.env.PORT || config.port,
2014-10-11 08:35:28 -04:00
bind: program.bind || config.bind,
public: mode
});
}
});