-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
52 lines (45 loc) · 1.21 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'use strict'
const vorpal = require('vorpal')()
const Auth = require('./lib/auth')
const Game = require('./lib/game')
const Preferences = require('preferences')
const PubSub = require('pubsub-js')
const clear = require('clui').Clear
const figlet = require('figlet')
const firebase = require('firebase')
const pkg = require('./package.json')
const config = new Preferences(pkg.name, { user: {} })
const chalk = vorpal.chalk
module.exports = {
vorpal,
firebase,
config,
PubSub,
auth: new Auth(firebase, config),
game: new Game(config, vorpal, firebase, PubSub)
}
// Show banner
clear()
vorpal.log(
chalk.yellow(figlet.textSync('SpiceTraders', {
font: 'Small Slant'
}))
)
vorpal.log(chalk.bold.green('\n Online Space Trading MMORPG'))
vorpal.log(chalk.cyan(` Version ${pkg.version}`))
// Fetch and instantiate all commands
require('./commands')()
// Initialize Auth and Game classes
vorpal
.exec('login -c')
// Initiate REPL command listening
vorpal
.delimiter('spicetraders')
.show()
// Catch any unknown commands
vorpal
.catch('[words...]', 'Catches incorrect commands')
.action(function (args, cb) {
this.log(args.words.join(' ') + ' is not a valid SpiceTraders command.\n');
cb();
});