2022-06-18 20:25:21 -04:00
|
|
|
import log from "../../log";
|
|
|
|
import colors from "chalk";
|
|
|
|
import {Command} from "commander";
|
|
|
|
import Utils from "../utils";
|
2014-09-13 17:29:45 -04:00
|
|
|
|
2022-06-18 20:25:21 -04:00
|
|
|
const program = new Command("list");
|
2014-09-13 17:29:45 -04:00
|
|
|
program
|
2014-10-03 19:33:44 -04:00
|
|
|
.description("List all users")
|
2017-08-21 01:49:32 -04:00
|
|
|
.on("--help", Utils.extraHelp)
|
2022-06-18 20:25:21 -04:00
|
|
|
.action(async function () {
|
|
|
|
const ClientManager = (await import("../../clientManager")).default;
|
2017-12-06 21:28:21 -05:00
|
|
|
const users = new ClientManager().getUsers();
|
2017-08-23 01:42:59 -04:00
|
|
|
|
2019-07-17 05:33:59 -04:00
|
|
|
if (users === undefined) {
|
|
|
|
// There was an error, already logged
|
2017-08-23 01:42:59 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-04-11 20:46:29 -04:00
|
|
|
if (users.length === 0) {
|
2019-07-17 05:33:59 -04:00
|
|
|
log.info(
|
|
|
|
`There are currently no users. Create one with ${colors.bold(
|
|
|
|
"thelounge add <name>"
|
|
|
|
)}.`
|
|
|
|
);
|
2022-04-11 20:46:29 -04:00
|
|
|
return;
|
2014-09-13 17:29:45 -04:00
|
|
|
}
|
2022-04-11 20:46:29 -04:00
|
|
|
|
|
|
|
log.info("Users:");
|
|
|
|
users.forEach((user, i) => {
|
|
|
|
log.info(`${i + 1}. ${colors.bold(user)}`);
|
|
|
|
});
|
2014-09-13 17:29:45 -04:00
|
|
|
});
|
2022-06-18 20:25:21 -04:00
|
|
|
|
|
|
|
export default program;
|