UNPKG

vodafone-station-cli

Version:

Access your Vodafone Station from the comfort of the command line.

37 lines (36 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const base_command_1 = tslib_1.__importStar(require("../base-command")); const discovery_1 = require("../modem/discovery"); class Discover extends base_command_1.default { static description = 'Try to discover a cable modem in the network'; static examples = [ '$ vodafone-station-cli discover', '$ vodafone-station-cli discover --ip 192.168.100.1', ]; static flags = { ip: (0, base_command_1.ipFlag)(), }; async discoverModem() { try { const { flags } = await this.parse(Discover); const discoveryOptions = { ip: flags.ip, }; const modemLocation = await (0, discovery_1.discoverModemLocation)(discoveryOptions); this.log(`Possibly found modem under the following location: ${JSON.stringify(modemLocation)}`); const modem = new discovery_1.ModemDiscovery(modemLocation, this.logger); const discoveredModem = await modem.discover(); this.log(`Discovered modem: ${JSON.stringify(discoveredModem)}`); } catch (error) { this.log('Something went wrong.', error); } } async run() { await this.discoverModem(); this.exit(); } } exports.default = Discover;