UNPKG

@iotize/cli

Version:
84 lines 3.96 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const clime_1 = require("clime"); const device_1 = require("../../../options/device"); const device_client_js_1 = require("@iotize/device-client.js"); const ui_1 = require("src/ui"); class MyOptions extends device_1.DeviceOptions { } exports.MyOptions = MyOptions; let VariableInfoCommand = class VariableInfoCommand extends clime_1.Command { constructor() { super(...arguments); this.help = 'Print variable infos'; this.command = 'variables'; } execute(variableId, options) { return __awaiter(this, void 0, void 0, function* () { const tap = yield options.getDevice(); yield this.run({ tap }, { options: { variableId } }); }); } run(context, args) { var _a, _b; return __awaiter(this, void 0, void 0, function* () { const { tap } = context; const variableId = (_b = (_a = args) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.variableId; if (variableId !== undefined) { const variable = yield tap.variables.getConfiguredVariable(variableId); ui_1.display.pretty(userfriendlyConf(variable.config)); } else { const variables = yield tap.variables.getConfiguredVariables(); ui_1.display.pretty(variables.map(variable => userfriendlyConf(variable.config))); } }); } }; __decorate([ clime_1.metadata, __param(0, clime_1.param({ description: 'required parameter foo', name: 'variable-id' })), __metadata("design:type", Function), __metadata("design:paramtypes", [Number, MyOptions]), __metadata("design:returntype", Promise) ], VariableInfoCommand.prototype, "execute", null); VariableInfoCommand = __decorate([ clime_1.command({ description: 'Print variable infos' }) ], VariableInfoCommand); exports.default = VariableInfoCommand; function userfriendlyConf(conf) { const formattedConf = conf; formattedConf.type = device_client_js_1.VariableType[conf.type]; return conf; } //# sourceMappingURL=info.js.map