hardlounge/index.js

53 lines
1.0 KiB
JavaScript
Raw Normal View History

2014-08-05 08:32:25 +00:00
#!/usr/bin/env node
process.chdir(__dirname);
2014-08-05 08:44:21 +00:00
var config = require("./config.json");
2014-08-05 08:32:25 +00:00
var program = require("commander");
2014-08-13 23:43:11 +00:00
var ClientManager = require("./src/clientManager");
2014-08-05 08:32:25 +00:00
var shout = require("./src/server.js");
2014-08-05 08:44:21 +00:00
program
.option("-p, --port <port>");
2014-08-05 08:32:25 +00:00
program
.command("start")
2014-08-05 08:44:21 +00:00
.description("Start the server")
2014-08-05 08:32:25 +00:00
.action(function() {
2014-08-05 08:44:21 +00:00
var port = program.port || config.port;
shout(port);
2014-08-05 08:32:25 +00:00
});
2014-08-13 23:43:11 +00:00
program
.command("list-users")
.description("List all existing users")
.action(function() {
var manager = new ClientManager();
var users = manager.getUsers();
for (var u in users) {
console.log(users[u]);
}
});
program
.command("add-user <name>")
.description("Add a new user")
.action(function(name) {
var manager = new ClientManager();
manager.addUser(name);
});
program
.command("remove-user <name>")
.description("Remove an existing user")
.action(function(name) {
var manager = new ClientManager();
manager.removeUser(name);
});
2014-08-05 08:32:25 +00:00
program.parse(process.argv)
if (!program.args.length) {
program.help();
}