2016-10-09 19:14:02 +00:00
|
|
|
"use strict";
|
|
|
|
|
2016-04-28 18:36:09 +00:00
|
|
|
global.log = require("../log.js");
|
2016-04-16 11:32:38 +00:00
|
|
|
|
2014-08-19 01:18:40 +00:00
|
|
|
var program = require("commander");
|
2016-12-15 06:13:43 +00:00
|
|
|
var colors = require("colors/safe");
|
2014-10-03 23:33:44 +00:00
|
|
|
var fs = require("fs");
|
2016-06-09 22:42:23 +00:00
|
|
|
var fsextra = require("fs-extra");
|
2016-05-08 06:21:31 +00:00
|
|
|
var path = require("path");
|
2014-10-03 23:33:44 +00:00
|
|
|
var Helper = require("../helper");
|
2014-08-19 01:18:40 +00:00
|
|
|
|
2017-02-18 03:23:01 +00:00
|
|
|
program.version(Helper.getVersion(), "-v, --version")
|
2017-08-16 03:30:01 +00:00
|
|
|
.option("--home <path>", `${colors.bold("[DEPRECATED]")} Use the ${colors.green("LOUNGE_HOME")} environment variable instead.`)
|
2017-02-18 03:23:01 +00:00
|
|
|
.parseOptions(process.argv);
|
2016-05-09 16:19:16 +00:00
|
|
|
|
2017-08-15 18:57:47 +00:00
|
|
|
if (program.home) {
|
2017-08-16 03:30:01 +00:00
|
|
|
log.warn(`${colors.green("--home")} is ${colors.bold("deprecated")} and will be removed in a future version.`);
|
|
|
|
log.warn(`Use the ${colors.green("LOUNGE_HOME")} environment variable instead.`);
|
2017-08-15 18:57:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let home = program.home || process.env.LOUNGE_HOME;
|
|
|
|
|
|
|
|
if (!home) {
|
|
|
|
const distConfig = path.resolve(path.join(
|
|
|
|
__dirname,
|
|
|
|
"..",
|
|
|
|
"..",
|
|
|
|
".lounge_config"
|
|
|
|
));
|
|
|
|
|
|
|
|
home = fs.readFileSync(distConfig, "utf-8").trim();
|
|
|
|
}
|
|
|
|
|
|
|
|
Helper.setHome(home);
|
2014-10-03 23:33:44 +00:00
|
|
|
|
2016-05-08 06:21:31 +00:00
|
|
|
if (!fs.existsSync(Helper.CONFIG_PATH)) {
|
2016-06-09 22:42:23 +00:00
|
|
|
fsextra.ensureDirSync(Helper.HOME);
|
|
|
|
fs.chmodSync(Helper.HOME, "0700");
|
|
|
|
fsextra.copySync(path.resolve(path.join(
|
|
|
|
__dirname,
|
|
|
|
"..",
|
|
|
|
"..",
|
|
|
|
"defaults",
|
|
|
|
"config.js"
|
|
|
|
)), Helper.CONFIG_PATH);
|
2016-12-15 06:13:43 +00:00
|
|
|
log.info(`Configuration file created at ${colors.green(Helper.CONFIG_PATH)}.`);
|
2014-10-14 20:53:26 +00:00
|
|
|
}
|
|
|
|
|
2016-06-09 22:42:23 +00:00
|
|
|
fsextra.ensureDirSync(Helper.USERS_PATH);
|
|
|
|
|
2016-04-19 20:58:49 +00:00
|
|
|
require("./start");
|
|
|
|
require("./config");
|
|
|
|
require("./list");
|
|
|
|
require("./add");
|
|
|
|
require("./remove");
|
|
|
|
require("./reset");
|
|
|
|
require("./edit");
|
|
|
|
|
2017-02-18 03:23:01 +00:00
|
|
|
program.parse(process.argv);
|
2014-10-14 20:53:26 +00:00
|
|
|
|
2014-08-19 01:18:40 +00:00
|
|
|
if (!program.args.length) {
|
2017-02-18 03:23:01 +00:00
|
|
|
program.help();
|
2014-08-19 01:18:40 +00:00
|
|
|
}
|