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");
|
2014-08-26 18:15:17 +00:00
|
|
|
var pkg = require("../../package.json");
|
2014-10-03 23:33:44 +00:00
|
|
|
var fs = require("fs");
|
|
|
|
var mkdirp = require("mkdirp");
|
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
|
|
|
|
2014-09-15 19:50:57 +00:00
|
|
|
program.version(pkg.version, "-v, --version");
|
2014-10-14 20:53:26 +00:00
|
|
|
program.option("");
|
|
|
|
program.option(" --home <path>" , "home path");
|
2014-09-15 19:50:57 +00:00
|
|
|
|
2014-10-14 20:53:26 +00:00
|
|
|
var argv = program.parseOptions(process.argv);
|
2016-05-09 16:19:16 +00:00
|
|
|
|
|
|
|
Helper.setHome(program.home);
|
2014-10-03 23:33:44 +00:00
|
|
|
|
2016-05-08 06:21:31 +00:00
|
|
|
if (!fs.existsSync(Helper.CONFIG_PATH)) {
|
2016-03-19 20:33:15 +00:00
|
|
|
mkdirp.sync(Helper.HOME, {mode: "0700"});
|
2014-11-06 11:48:10 +00:00
|
|
|
fs.writeFileSync(
|
2016-05-08 06:21:31 +00:00
|
|
|
Helper.CONFIG_PATH,
|
|
|
|
fs.readFileSync(path.resolve(path.join(
|
|
|
|
__dirname,
|
|
|
|
"..",
|
|
|
|
"..",
|
|
|
|
"defaults",
|
|
|
|
"config.js"
|
|
|
|
)))
|
2014-11-06 11:48:10 +00:00
|
|
|
);
|
2016-05-08 06:21:31 +00:00
|
|
|
log.info("Config created:", Helper.CONFIG_PATH);
|
2014-10-14 20:53:26 +00:00
|
|
|
}
|
|
|
|
|
2016-04-19 20:58:49 +00:00
|
|
|
require("./start");
|
|
|
|
require("./config");
|
|
|
|
require("./list");
|
|
|
|
require("./add");
|
|
|
|
require("./remove");
|
|
|
|
require("./reset");
|
|
|
|
require("./edit");
|
|
|
|
|
2014-10-14 20:53:26 +00:00
|
|
|
program.parse(argv.args);
|
|
|
|
|
2014-08-19 01:18:40 +00:00
|
|
|
if (!program.args.length) {
|
|
|
|
program.parse(process.argv.concat("start"));
|
|
|
|
}
|