How to use the homebridge-lib.OptionParser function in homebridge-lib

To help you get started, we’ve selected a few homebridge-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ebaauw / homebridge-hue / lib / HueClient.js View on Github external
constructor (options = {}) {
    this._debug = debug('HueClient' + ++id)
    this._debug('constructor(%j)', options)
    this._options = {
      hostname: 'localhost',
      port: 80,
      timeout: 5
    }
    const optionParser = new homebridgeLib.OptionParser(this._options)
    optionParser.stringKey('bridgeid', true)
    optionParser.hostKey()
    optionParser.stringKey('fingerprint', true)
    optionParser.boolKey('phoscon')
    optionParser.stringKey('username', true)
    optionParser.intKey('timeout', 1, 60)
    optionParser.parse(options)
    if (this._options.fingerprint != null) {
      this._options.https = true
    }
    this._options.url = this._options.https ? 'https://' : 'http://'
    this._options.url += this._options.hostname
    if (this._options.port !== 80) {
      this._options.url += ':' + this._options.port
    }
    this._debug('constructor() => %j', this._options)
github ebaauw / homebridge-hue / lib / HueDiscovery.js View on Github external
constructor (options = {}) {
    this._debug = debug('HueDiscovery' + ++id)
    this._debug('constructor(%j)', options)
    this._options = {
      timeout: 5
    }
    const optionParser = new homebridgeLib.OptionParser(this._options)
    optionParser.boolKey('verbose')
    optionParser.intKey('timeout', 1, 60)
    optionParser.parse(options)
    this._debug('constructor(%j) => %j', options, this._options)
  }