hardlounge/src/command-line/edit.js

23 lines
624 B
JavaScript
Raw Normal View History

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