-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
60 lines (52 loc) · 1.54 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env node
var app = {
requestify : require('requestify'),
fs : require('fs'),
exec : require('child_process').exec,
chalk : require("chalk"),
clear : require("clear"),
figlet : require("figlet"),
git : require("simple-git/promise"),
program : require("commander"),
prompt : require("prompt"),
fileutils : require("./utils/file.utils")(),
package : require("./package.json")
};
app.alertutils = require("./utils/alert.utils")(app),
app.updateapputils = require("./utils/update-app.utils")(app),
app.program.name('etron').version(app.package.version);
// Show the name and version for etron.
app.clear();
console.log(
app.chalk.bold.redBright(
app.figlet.textSync("eTron", { horizontalLayout: "full" })
),
app.chalk.yellowBright(app.package.version)
);
var files = app.fileutils._getAllFilesFromFolder(__dirname + "/command/");
/**
* populate options for program
*/
for (let i = 0; i < files.length; i++) {
try {
var memCo = require(files[i])(app);
app.program.option(memCo.command + ", " + memCo.flag, memCo.description);
} catch (e) {
console.log(app.chalk.red("Erro: " + e));
}
}
// parse - argv
app.program.parse(process.argv);
//bootstrap for command
for (let i = 0; i < files.length; i++) {
var memCo = require(files[i])(app);
let fu = eval("app.program." + memCo.flag.replace("--", ""));
if (fu) {
memCo.bootstrap();
return;
}
}
//case not say command, show the options
if (!app.program.args.length) {
app.program.help();
}