thelounge/src/command-line/users/list.js

35 lines
737 B
JavaScript
Raw Normal View History

"use strict";
2018-06-15 20:31:06 +00:00
const log = require("../../log");
2018-03-02 18:28:54 +00:00
const colors = require("chalk");
const program = require("commander");
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")
.on("--help", Utils.extraHelp)
.action(function () {
const ClientManager = require("../../clientManager");
const users = new ClientManager().getUsers();
2019-07-17 09:33:59 +00:00
if (users === undefined) {
// There was an error, already logged
return;
}
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>"
)}.`
);
return;
2014-09-13 21:29:45 +00:00
}
log.info("Users:");
users.forEach((user, i) => {
log.info(`${i + 1}. ${colors.bold(user)}`);
});
2014-09-13 21:29:45 +00:00
});