-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
54 lines (42 loc) · 1000 Bytes
/
index.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
const minimist = require('minimist');
const error = require('./src/utils/error');
const convert = require('./src/utils/convert');
module.exports = () => {
const args = minimist(process.argv.slice(2));
const restArgs = minimist(process.argv);
/* ---------------------------------- code ---------------------------------- */
let [arg] = args._;
let cmd = arg || 'help';
if (args.version || args.v) {
cmd = 'version';
}
if (arg && arg.length > 1) {
cmd = 'file';
}
if (args.preview || args.p) {
cmd = 'preview';
}
if (args.help || args.h) {
cmd = 'help';
}
switch (cmd) {
case 'file':
require('./src/commands/index')(args);
break;
case 'version':
require('./src/commands/version')(restArgs);
break;
case 'preview':
require('./src/commands/preview')(restArgs);
break;
case 'help':
require('./src/commands/help')(restArgs);
break;
default:
error(`"${cmd}" is not a valid command!`);
break;
}
};
module.exports = {
...convert,
};