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