hardlounge/src/command-line/start.js

37 lines
1023 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 12:35:28 +00: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 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!");
console.log("Create a new user with 'lounge add <name>'.");
console.log("");
} else {
server({
2014-10-14 18:47:49 +00:00
host: program.host || process.env.IP || config.host,
port: program.port || process.env.PORT || config.port,
2014-10-11 12:35:28 +00:00
bind: program.bind || config.bind,
public: mode
});
}
});