How to use the homebridge-lib.CommandLineTool 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 / cli / ph.js View on Github external
${b('-v')}          Verbose.
  ${b('-t')} ${u('timeout')}  Timeout after ${u('timeout')} minutes (default: 5).
  ${u('light')}       Light resource to probe.`,
  restart: `${description.ph}

Usage: ${b('ph')} ${usage.restart}

${description.restart}
Note: this command is not supported on a Hue bridge.

Parameters:
  ${b('-h')}          Print this help and exit.
  ${b('-v')}          Verbose.`
}

class Main extends homebridgeLib.CommandLineTool {
  constructor () {
    super({ mode: 'command', debug: false })
    this.usage = usage.ph
    try {
      this._readBridges()
    } catch (err) {
      if (err.code !== 'ENOENT') {
        this.error(err)
      }
      this.bridges = {}
    }
  }

  // ===========================================================================

  _readBridges () {
github ebaauw / homebridge-hue / cli / dc_eventlog.js View on Github external
const usage = `${b('dc_eventlog')} [${b('-hVnrs')}] [${b('--host=')}${u('hostname')}[${b(':')}${u('port')}]]`
const help = `Logger for deCONZ websocket notifications.

Usage: ${usage}

Log deCONZ websocket notifications to stdout.
Parameters:
  ${b('-h')}          Print this help and exit.
  ${b('-V')}          Print version and exit.
  ${b('-n')}          Do not retry when websocket connection is closed.
  ${b('-r')}          Do not parse events, output raw event data.
  ${b('-s')}          Do not output timestamps (useful when running as service).
  ${b('-H')} ${u('hostname')}[${b(':')}${u('port')}]
              Connect to ${u('hostname')}${b(':')}${u('port')} instead of the default ${b('localhost:443')}.`

class Main extends homebridgeLib.CommandLineTool {
  constructor () {
    super()
    this.usage = usage
    this.options = {
      mode: 'daemon'
    }
    this.ws = {}
  }

  parseArguments () {
    const parser = new homebridgeLib.CommandLineParser(packageJson)
    parser.help('h', 'help', help)
    parser.version('V', 'version')
    parser.option('H', 'host', (value) => {
      homebridgeLib.OptionParser.toHost('host', value, true)
      this.ws.host = value