hardlounge/src/command-line/edit.js

21 lines
552 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.getUserConfigPath("<name>"))
2014-08-25 00:19:03 +00:00
.action(function(name) {
var users = new ClientManager().getUsers();
if (users.indexOf(name) === -1) {
2016-04-16 11:32:38 +00:00
log.error("User '" + name + "' doesn't exist.");
2014-08-25 00:19:03 +00:00
return;
}
child.spawn(
process.env.EDITOR || "vi",
[Helper.getUserConfigPath(name)],
2014-08-25 00:19:03 +00:00
{stdio: "inherit"}
);
});