32 lines
783 B
JavaScript
32 lines
783 B
JavaScript
"use strict";
|
|
|
|
const colors = require("colors/safe");
|
|
const program = require("commander");
|
|
const fs = require("fs");
|
|
const Helper = require("../../helper");
|
|
const Utils = require("../utils");
|
|
|
|
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
|
|
}
|
|
});
|