UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

33 lines 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deviceList = exports.getDeviceList = void 0; const alwayscli_1 = require("@alwaysai/alwayscli"); const cli_inputs_1 = require("../../cli-inputs"); const user_1 = require("../../components/user"); const infrastructure_1 = require("../../infrastructure"); async function getDeviceList() { const { username } = await (0, infrastructure_1.CliAuthenticationClient)().getInfo(); const deviceList = await (0, infrastructure_1.CliRpcClient)().getUserDevices({ user_name: username }); return deviceList; } exports.getDeviceList = getDeviceList; exports.deviceList = (0, alwayscli_1.CliLeaf)({ name: 'list', description: 'List all available devices', namedInputs: { yes: cli_inputs_1.yesCliInput }, async action(_, { yes }) { await (0, user_1.checkUserIsLoggedInComponent)({ yes }); const deviceList = await getDeviceList(); const deviceTable = deviceList.reduce((acc, device) => { const { uuid, friendly_name, description, host_name } = device; acc[uuid] = { name: friendly_name, description, address: host_name }; return acc; }, {}); console.table(deviceTable); } }); //# sourceMappingURL=list.js.map