-
Notifications
You must be signed in to change notification settings - Fork 2
/
web
executable file
·63 lines (53 loc) · 1.24 KB
/
web
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
61
62
63
#!/usr/bin/env node
const chalk = require('chalk')
const api = require('./api')
const group = require('./modules/group')
const commands = require('./modules/commands')
const execute = require('./modules/execute')
const help = require('./modules/help')
const print = require('./modules/print')
const list = require('./modules/list')
const error = require('./modules/error')
const command = process.argv[2]
const args = process.argv.slice(3)
switch (command) {
case 'ls':
case 'list':
if(args.length !== 0) {
error('Nope, not using that right!')
help()
break
}
print(api)
break
case 'groups':
list(api, args)
break
case 'open':
case 'run':
if (args.length === 1) {
if (api.listExists(args[0])) {
execute(api, args[0])
break
} else {
error('Group not found.')
break
}
} else {
error('Nope, not using that right!')
help()
break
}
case 'help':
case undefined:
help()
break
default:
if (api.listExists(command)) {
group(api, args, command)
} else {
error('Group not found. Did you mean to do something else?')
help('root')
}
}
api.save()