hardlounge/src/command-line/users/remove.js

33 lines
812 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 fs = require("fs");
const Helper = require("../../helper");
const Utils = require("../utils");
2014-09-13 21:29:45 +00:00
program
.command("remove <name>")
.description("Remove an existing user")
.on("--help", Utils.extraHelp)
.action(function (name) {
if (!fs.existsSync(Helper.getUsersPath())) {
log.error(`${Helper.getUsersPath()} does not exist.`);
return;
}
const ClientManager = require("../../clientManager");
const manager = new ClientManager();
try {
if (manager.removeUser(name)) {
log.info(`User ${colors.bold(name)} removed.`);
} else {
log.error(`User ${colors.bold(name)} does not exist.`);
}
} catch (e) {
// There was an error, already logged
2014-09-13 21:29:45 +00:00
}
});