UNPKG

visualise-elastic-profile

Version:

Visualise results from Profile API of ElasticSearch on the command line

62 lines 2.66 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); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CommandOptions = void 0; const clime_1 = require("clime"); const castable_1 = require("clime/bld/castable"); const index_1 = require("../index"); class CommandOptions extends clime_1.Options { } __decorate([ (0, clime_1.option)({ description: 'enable/disable coloring the output', default: false, toggle: true, }), __metadata("design:type", Boolean) ], CommandOptions.prototype, "noColor", void 0); __decorate([ (0, clime_1.option)({ description: 'max width of the output', default: undefined, }), __metadata("design:type", Number) ], CommandOptions.prototype, "maxWidth", void 0); exports.CommandOptions = CommandOptions; let default_1 = class default_1 extends clime_1.Command { async execute(profileFile, options) { var _a; const maxWidth = (_a = options.maxWidth) !== null && _a !== void 0 ? _a : process.stdout.columns; const parsedProfile = await profileFile.json(); console.log((0, index_1.stringifyProfile)(parsedProfile, { maxWidth, color: !options.noColor })); } }; __decorate([ __param(0, (0, clime_1.param)({ description: 'JSON of the profile data', required: true, type: castable_1.File, })), __metadata("design:type", Function), __metadata("design:paramtypes", [castable_1.File, CommandOptions]), __metadata("design:returntype", Promise) ], default_1.prototype, "execute", null); default_1 = __decorate([ (0, clime_1.command)({ description: 'This is a command for visualising ElasticSearch search profile', }) ], default_1); exports.default = default_1; //# sourceMappingURL=default.js.map