thelounge/src/command-line/index.js
2016-03-19 18:59:45 -04:00

40 lines
893 B
JavaScript

var program = require("commander");
var pkg = require("../../package.json");
var fs = require("fs");
var mkdirp = require("mkdirp");
var Helper = require("../helper");
program.version(pkg.version, "-v, --version");
program.option("");
program.option(" --home <path>" , "home path");
require("./start");
require("./config");
require("./list");
require("./add");
require("./remove");
require("./reset");
require("./edit");
var argv = program.parseOptions(process.argv);
if (program.home) {
Helper.HOME = program.home;
}
var config = Helper.HOME + "/config.js";
if (!fs.existsSync(config)) {
mkdirp.sync(Helper.HOME, {mode: "0700"});
fs.writeFileSync(
config,
fs.readFileSync(__dirname + "/../../defaults/config.js")
);
console.log("Config created:");
console.log(config);
}
program.parse(argv.args);
if (!program.args.length) {
program.parse(process.argv.concat("start"));
}