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-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")
|
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 {
|
2014-10-11 12:35:28 +00:00
|
|
|
shout({
|
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
|
|
|
|
});
|
2014-09-09 11:12:23 +00:00
|
|
|
}
|
|
|
|
});
|