-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·41 lines (34 loc) · 1.24 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
#!/usr/bin/env node
'use strict'
const vorpal = require('vorpal')()
const config = require('standard-settings').getSettings().service.spacebro
const spacebro = require('./src/initSpacebro')
vorpal.warn = console.warn
vorpal.error = console.error
let subscribe = null
let unsubscribe = null
let emit = null
spacebro.init(config, vorpal)
.then((client) => {
subscribe = require('./src/commands')(client, vorpal).subscribe
unsubscribe = require('./src/commands')(client, vorpal).unsubscribe
emit = require('./src/commands')(client, vorpal).emit
vorpal
.command('subscribe <event>', 'Start listening to a specific spacebro event.')
.action(subscribe)
vorpal
.command('unsubscribe <event>', 'Stop listening to a specific spacebro event.')
.action(unsubscribe)
vorpal
.command('emit <event> [data]', 'Emits a spacebro event with optional data. JSON must be surrounded by quotes.')
.option('--interval <seconds>', 'The event will be emitted at specified interval (in seconds).')
.option('--stop', 'Stops the interval for a given spacebro event.')
.action(emit)
vorpal.show()
})
.catch((err) => {
console.error(err)
process.exit(1)
})
vorpal
.delimiter('spacebro-client$')