2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2017-07-18 09:36:24 +00:00
|
|
|
const colors = require("colors/safe");
|
|
|
|
const program = require("commander");
|
|
|
|
const fs = require("fs");
|
2017-08-23 05:15:01 +00:00
|
|
|
const Helper = require("../helper");
|
2017-08-21 05:49:32 +00:00
|
|
|
const Utils = require("./utils");
|
2014-09-13 21:29:45 +00:00
|
|
|
|
|
|
|
program
|
|
|
|
.command("list")
|
2014-10-03 23:33:44 +00:00
|
|
|
.description("List all users")
|
2017-08-21 05:49:32 +00:00
|
|
|
.on("--help", Utils.extraHelp)
|
2014-09-13 21:29:45 +00:00
|
|
|
.action(function() {
|
2017-07-18 09:36:24 +00:00
|
|
|
if (!fs.existsSync(Helper.USERS_PATH)) {
|
|
|
|
log.error(`${Helper.USERS_PATH} does not exist.`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ClientManager = require("../clientManager");
|
|
|
|
|
2017-08-23 05:15:01 +00:00
|
|
|
if (Helper.config.public) {
|
|
|
|
log.warn(`Users have no effect in ${colors.bold("public")} mode.`);
|
|
|
|
}
|
|
|
|
|
2014-09-13 21:29:45 +00:00
|
|
|
var users = new ClientManager().getUsers();
|
2017-08-23 05:42:59 +00:00
|
|
|
|
|
|
|
if (users === undefined) { // There was an error, already logged
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-08-26 04:55:49 +00:00
|
|
|
if (users.length > 0) {
|
2016-12-15 06:13:43 +00:00
|
|
|
log.info("Users:");
|
2017-08-26 04:55:49 +00:00
|
|
|
users.forEach((user, i) => {
|
|
|
|
log.info(`${i + 1}. ${colors.bold(user)}`);
|
|
|
|
});
|
|
|
|
} else {
|
2017-11-12 20:49:04 +00:00
|
|
|
log.info(`There are currently no users. Create one with ${colors.bold("thelounge add <name>")}.`);
|
2014-09-13 21:29:45 +00:00
|
|
|
}
|
|
|
|
});
|