forked from DeviaVir/zenbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zenbot.js
40 lines (35 loc) · 997 Bytes
/
zenbot.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
var semver = require('semver')
var version = require('./package.json').version
USER_AGENT = 'zenbot/' + version
var program = require('commander')
program.version(version)
program._name = 'zenbot'
var versions = process.versions
if (semver.gt('8.3.0', versions.node)) {
console.log('You are running a node.js version older than 8.3.x, please upgrade via https://nodejs.org/en/')
process.exit(1)
}
var fs = require('fs')
, path = require('path')
, boot = require('./boot')
boot(function (err, zenbot) {
var command_name = process.argv[2]
if (err) {
throw err
}
var commands = zenbot.get('zenbot:commands.list')
commands.forEach(function (command) {
command(program)
})
var command_found = false
try {
zenbot.get('zenbot:commands.' + command_name)
command_found = true
}
catch (e) {
}
if (!command_name || !command_found && (!process.argv[2] || !process.argv[2].match(/^-V|--version$/))) {
program.help()
}
program.parse(process.argv)
})