mqtt.js 990 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env node
  2. 'use strict'
  3. /*
  4. * Copyright (c) 2015-2015 MQTT.js contributors.
  5. * Copyright (c) 2011-2014 Adam Rudd.
  6. *
  7. * See LICENSE for more information
  8. */
  9. var MqttClient = require('./lib/client')
  10. var connect = require('./lib/connect')
  11. var Store = require('./lib/store')
  12. module.exports.connect = connect
  13. // Expose MqttClient
  14. module.exports.MqttClient = MqttClient
  15. module.exports.Client = MqttClient
  16. module.exports.Store = Store
  17. function cli () {
  18. var commist = require('commist')()
  19. var helpMe = require('help-me')()
  20. commist.register('publish', require('./bin/pub'))
  21. commist.register('subscribe', require('./bin/sub'))
  22. commist.register('version', function () {
  23. console.log('MQTT.js version:', require('./package.json').version)
  24. })
  25. commist.register('help', helpMe.toStdout)
  26. if (commist.parse(process.argv.slice(2)) !== null) {
  27. console.log('No such command:', process.argv[2], '\n')
  28. helpMe.toStdout()
  29. }
  30. }
  31. if (require.main === module) {
  32. cli()
  33. }