UNPKG

skysync-cli

Version:

SkySync Command Line Interface

72 lines (71 loc) 2.42 kB
"use strict"; 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()); }); }; const command_1 = require("../../util/command"); const outputFormat = { table: [ { header: 'Metric', property: 'name' }, { header: 'Value', property: 'value' }, { header: 'Type', property: 'type' } ] }; module.exports = { command: 'metrics', desc: 'List all Diagnostic Metrics', builder: yargs => { yargs.options({ 'type': { alias: 't', desc: 'Metric type', type: 'string', group: 'Search' }, 'name': { alias: 'm', desc: 'Metric name', type: 'string', group: 'Search' }, 'search': { alias: 'q', desc: 'Search text', type: 'string', group: 'Search' } }); }, handler: argv => { command_1.runCommand(argv, (client, output) => __awaiter(void 0, void 0, void 0, function* () { const metrics = yield client.diagnosticMetrics.list({ type: argv.type, name: argv.name, q: argv.search }); let mappedMetrics = Object.keys(metrics).map(name => { const metric = metrics[name]; return { name: name, value: metric.value, type: metric.type }; }); output.writeTable(mappedMetrics, outputFormat); })); } };