thelounge/src/command-line/index.js

46 lines
1 KiB
JavaScript
Raw Normal View History

"use strict";
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");
var colors = require("colors/safe");
2014-10-03 23:33:44 +00:00
var fs = require("fs");
var fsextra = require("fs-extra");
var path = require("path");
2014-10-03 23:33:44 +00:00
var Helper = require("../helper");
2014-08-19 01:18:40 +00:00
program.version(Helper.getVersion(), "-v, --version")
.option("--home <path>", "path to configuration folder")
.parseOptions(process.argv);
2016-05-09 16:19:16 +00:00
Helper.setHome(program.home || process.env.LOUNGE_HOME);
2014-10-03 23:33:44 +00:00
if (!fs.existsSync(Helper.CONFIG_PATH)) {
fsextra.ensureDirSync(Helper.HOME);
fs.chmodSync(Helper.HOME, "0700");
fsextra.copySync(path.resolve(path.join(
__dirname,
"..",
"..",
"defaults",
"config.js"
)), Helper.CONFIG_PATH);
log.info(`Configuration file created at ${colors.green(Helper.CONFIG_PATH)}.`);
2014-10-14 20:53:26 +00:00
}
fsextra.ensureDirSync(Helper.USERS_PATH);
require("./start");
require("./config");
require("./list");
require("./add");
require("./remove");
require("./reset");
require("./edit");
program.parse(process.argv);
2014-10-14 20:53:26 +00:00
2014-08-19 01:18:40 +00:00
if (!program.args.length) {
program.help();
2014-08-19 01:18:40 +00:00
}