UNPKG

@platformos/pos-cli

Version:
41 lines (34 loc) 1.35 kB
#!/usr/bin/env node import { program } from '../lib/program.js'; import logger from '../lib/logger.js'; import { SwaggerProxy } from '../lib/swagger-client.js'; import { search } from '../lib/swagger-client.js'; import path from 'path'; import { fileURLToPath } from 'url'; import fs from 'fs'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); program.showHelpAfterError(); program .name('pos-cli logsv2 reports') .arguments('[environment]', 'name of environment. Example: staging') .option('--json', 'output as json') // .option('--from <from>', 'start from', 0) // .option('--size <size>', 'rows size', 20) // .option('--start_time <st>', 'starttime') // .option('--end_time <et>', 'endtime') .requiredOption('--report <report>', 'available reports: r-4xx, r-slow, r-slow-by-count') .action(async (environment, program) => { try { const client = await SwaggerProxy.client(environment); const report = JSON.parse(fs.readFileSync(path.join(__dirname, `../lib/reports/${program.report}.json`))); const response = await client.searchSQLByQuery(report); if (!program.json) search.printReport(response, report); else console.log(JSON.stringify(response)); } catch(e) { logger.Error(e); } }); program.parse(process.argv);