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",
"description": "A web IRC client",
"version": "0.10.5",
"version": "0.10.6",
"author": "Mattias Erming",
"preferGlobal": true,
"bin": {

View File

@ -7,7 +7,7 @@ program
.action(function() {
child.spawn(
"sudo",
["vim", process.cwd() + "/config.json"],
["vi", process.cwd() + "/config.json"],
{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("./add");
require("./remove");
require("./edit");
program
.option("-p, --port <port>")

View File

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