-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.js
46 lines (36 loc) · 905 Bytes
/
cli.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
#!/usr/bin/env node
// import all commands from their respective files
let generate = require('./commands/generate')
let solution = require('./commands/solution')
let preview = require('./commands/preview')
let cheat = require('./commands/cheat')
let help = require('./commands/help')
// parse command line arguments
let command = process.argv[2]
let question = process.argv[3]
let language = process.argv[4]
// execute the proper command based on arguements
switch (command) {
case 'generate':
case 'g':
generate(question, language)
break
case 'solution':
case 's':
solution(question, language)
break
case 'preview':
case 'p':
preview(question)
break
case 'cheat':
case 'c':
cheat(question)
break
case 'help':
case 'h':
help()
break
default:
console.log('Invalid command syntax. Type \'help\' to see correct syntax.')
}