hardlounge/server/command-line/users/list.ts
Max Leiter dd05ee3a65
TypeScript and Vue 3 (#4559)
Co-authored-by: Eric Nemchik <eric@nemchik.com>
Co-authored-by: Pavel Djundik <xPaw@users.noreply.github.com>
2022-06-18 17:25:21 -07:00

35 lines
769 B
TypeScript

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