2016-10-09 19:14:02 +00:00
|
|
|
"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");
|
2017-07-18 09:36:24 +00:00
|
|
|
const program = require("commander");
|
|
|
|
const fs = require("fs");
|
2017-12-07 02:23:46 +00:00
|
|
|
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")
|
2017-08-21 05:49:32 +00:00
|
|
|
.on("--help", Utils.extraHelp)
|
2020-03-21 20:55:36 +00:00
|
|
|
.action(function (name) {
|
2017-12-07 03:54:54 +00:00
|
|
|
if (!fs.existsSync(Helper.getUsersPath())) {
|
|
|
|
log.error(`${Helper.getUsersPath()} does not exist.`);
|
2017-07-18 09:36:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-12-07 02:23:46 +00:00
|
|
|
const ClientManager = require("../../clientManager");
|
2017-08-23 05:42:59 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
});
|