-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (30 loc) · 829 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
const minimist = require('minimist')
module.exports = () => {
const args = minimist(process.argv.slice(2))
let cmd = args._[0]
if (args.i || args.init) { cmd = 'init' }
if (args.c || args.create) { cmd = 'create' }
if (args.h || args.help) { cmd = 'help' }
if (args.v || args.version) { cmd = 'version' }
switch (cmd) {
case 'init':
require('./cmds/init')()
break
case 'create':
require('./cmds/create')(args)
break
case 'help':
require('./cmds/help')(args)
break
case 'version':
require('./cmds/version')()
break
default:
if (cmd === undefined) {
console.log('Usage:\n ccreator [command] <options>\n ccreator help')
break;
}
console.error(`"${cmd}" is not a valid command!`)
break
}
}