-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcli.ts
47 lines (41 loc) · 992 Bytes
/
cli.ts
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
import './utils/logs'
import build from './build'
import create from './create'
import validate from './validate'
import * as help from './help'
export async function cli (rawArgs: string[]): Promise<void> {
const command: string = rawArgs[2]
const args = rawArgs.slice(3)
switch (command) {
case '--version':
case '-v':
const version = require('../package.json').version
console.log(`v${version}`)
return
case 'build':
if (args.length && ['--help', '-h'].includes(args[0])) {
help.build()
return
}
build(args)
break
case 'create':
if (args.length && ['--help', '-h'].includes(args[0])) {
help.create()
return
}
create(args)
break
case 'validate':
if (args.length && ['--help', '-h'].includes(args[0])) {
help.validate()
return
}
validate(args)
break
case '--help':
case '-h':
default:
help.main()
}
}