2014-08-25 00:19:03 +00:00
|
|
|
var ClientManager = new require("../clientManager");
|
|
|
|
var program = require("commander");
|
|
|
|
var child = require("child_process");
|
2014-09-13 12:23:17 +00:00
|
|
|
var Helper = require("../helper");
|
2014-08-26 18:00:12 +00:00
|
|
|
|
2014-08-25 00:19:03 +00:00
|
|
|
program
|
|
|
|
.command("edit <name>")
|
2014-10-23 02:37:29 +00:00
|
|
|
.description("Edit user: '" + Helper.HOME + "/users/<name>.json'")
|
2014-08-25 00:19:03 +00:00
|
|
|
.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(
|
2014-10-09 08:27:36 +00:00
|
|
|
process.env.EDITOR || "vi",
|
2014-10-23 02:37:29 +00:00
|
|
|
[require("path").join(Helper.HOME, "users", name + ".json")],
|
2014-08-25 00:19:03 +00:00
|
|
|
{stdio: "inherit"}
|
|
|
|
);
|
|
|
|
});
|