thelounge/server/command-line/users/list.ts

35 lines
769 B
TypeScript
Raw Normal View History

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