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);
	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"));
}

@@ -285,147 +285,8 @@
 );%0A%0A
-require(%22./start%22);%0Arequire(%22./config%22);%0Arequire(%22./list%22);%0Arequire(%22./add%22);%0Arequire(%22./remove%22);%0Arequire(%22./reset%22);%0Arequire(%22./edit%22);%0A%0A
 var 
@@ -628,16 +628,155 @@
 ig);%0A%7D%0A%0A
+require(%22./start%22);%0Arequire(%22./config%22);%0Arequire(%22./list%22);%0Arequire(%22./add%22);%0Arequire(%22./remove%22);%0Arequire(%22./reset%22);%0Arequire(%22./edit%22);%0A%0A
 program.

Fix loading config before HOME variable is set