Added 'shout edit' command

This commit is contained in:
Mattias Erming 2014-08-24 17:19:03 -07:00
parent 100d3dee18
commit 4c2e1e24f7
5 changed files with 25 additions and 4 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "shout", "name": "shout",
"description": "A web IRC client", "description": "A web IRC client",
"version": "0.10.5", "version": "0.10.6",
"author": "Mattias Erming", "author": "Mattias Erming",
"preferGlobal": true, "preferGlobal": true,
"bin": { "bin": {

View File

@ -7,7 +7,7 @@ program
.action(function() { .action(function() {
child.spawn( child.spawn(
"sudo", "sudo",
["vim", process.cwd() + "/config.json"], ["vi", process.cwd() + "/config.json"],
{stdio: "inherit"} {stdio: "inherit"}
); );
}); });

21
src/cli/edit.js Normal file
View File

@ -0,0 +1,21 @@
var ClientManager = new require("../clientManager");
var program = require("commander");
var child = require("child_process");
program
.command("edit <name>")
.description("Edit existing user")
.action(function(name) {
var users = new ClientManager().getUsers();
if (users.indexOf(name) === -1) {
console.log("");
console.log("User '" + name + "' doesn't exist.");
console.log("");
return;
}
child.spawn(
"sudo",
["vi", process.cwd() + "/users/" + name + "/user.json"],
{stdio: "inherit"}
);
});

View File

@ -5,6 +5,7 @@ require("./config");
require("./list"); require("./list");
require("./add"); require("./add");
require("./remove"); require("./remove");
require("./edit");
program program
.option("-p, --port <port>") .option("-p, --port <port>")

View File

@ -19,8 +19,7 @@ program
return; return;
} }
var manager = new ClientManager(); var manager = new ClientManager();
var success = manager.removeUser(name); if (manager.removeUser(name)) {
if (success) {
console.log(""); console.log("");
console.log("Removed '" + name + "'."); console.log("Removed '" + name + "'.");
console.log(""); console.log("");