forked from mqttjs/MQTT.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mqtt.js
executable file
·41 lines (33 loc) · 990 Bytes
/
mqtt.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'
/*
* Copyright (c) 2015-2015 MQTT.js contributors.
* Copyright (c) 2011-2014 Adam Rudd.
*
* See LICENSE for more information
*/
var MqttClient = require('./lib/client')
var connect = require('./lib/connect')
var Store = require('./lib/store')
module.exports.connect = connect
// Expose MqttClient
module.exports.MqttClient = MqttClient
module.exports.Client = MqttClient
module.exports.Store = Store
function cli () {
var commist = require('commist')()
var helpMe = require('help-me')()
commist.register('publish', require('./bin/pub'))
commist.register('subscribe', require('./bin/sub'))
commist.register('version', function () {
console.log('MQTT.js version:', require('./package.json').version)
})
commist.register('help', helpMe.toStdout)
if (commist.parse(process.argv.slice(2)) !== null) {
console.log('No such command:', process.argv[2], '\n')
helpMe.toStdout()
}
}
if (require.main === module) {
cli()
}