2014-09-09 11:12:23 +00:00
|
|
|
var ClientManager = new require("../clientManager");
|
|
|
|
var program = require("commander");
|
|
|
|
var shout = require("../server");
|
2014-10-01 15:59:35 +00:00
|
|
|
var Helper = require("../helper");
|
2014-09-09 11:12:23 +00:00
|
|
|
|
|
|
|
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")
|
2014-09-09 11:12:23 +00:00
|
|
|
.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();
|
2014-10-01 19:05:07 +00:00
|
|
|
var mode = config.public;
|
|
|
|
if (program.public) {
|
|
|
|
mode = true;
|
|
|
|
} else if (program.private) {
|
|
|
|
mode = false;
|
|
|
|
}
|
|
|
|
if (!mode && !users.length) {
|
2014-09-09 11:12:23 +00:00
|
|
|
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>'.");
|
2014-09-09 11:12:23 +00:00
|
|
|
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);
|
2014-09-09 11:12:23 +00:00
|
|
|
}
|
|
|
|
});
|