UNPKG

dirigera

Version:

A TypeScript client for IKEA's DIRIGERA smart home hub

32 lines (31 loc) 1.53 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const commander_1 = require("commander"); const index_1 = require("./index"); const package_json_1 = require("../package.json"); commander_1.program .version(package_json_1.version) .description('CLI utility to help get started with the dirigera library and to debug issues'); commander_1.program .command('authenticate') .description('Get an authentication token from your gateway') .option('--gateway-IP [string]', 'Optional. Use if mDNS discovery is not working.') .option('--no-reject-unauthorized', 'Optional. Use it to ignore certificate errors.') .action(async (options) => { const client = await (0, index_1.createDirigeraClient)(options); const accessToken = await client.authenticate({ verbose: true }); console.log(`🔑 Your access token: ${accessToken}`); }); commander_1.program .command('dump') .description('Dump a JSON of all device data from your gateway') .option('--gateway-IP [string]', 'Optional. Use if mDNS discovery is not working.') .requiredOption('--access-token <string>', `Get an access token by running 'dirigera authenticate' first!`) .option('--no-reject-unauthorized', 'Optional. Use it to ignore certificate errors.') .action(async (options) => { const client = await (0, index_1.createDirigeraClient)(options); const dump = await client.home(); console.log(JSON.stringify(dump, null, 2)); }); commander_1.program.parse();