UNPKG

fedapay-cli

Version:
82 lines (81 loc) 2.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const fedapay_1 = require("fedapay"); const json_colorizer_1 = tslib_1.__importDefault(require("json-colorizer")); const cli_ux_1 = require("cli-ux"); const chalk_1 = tslib_1.__importDefault(require("chalk")); const logs_1 = tslib_1.__importDefault(require("../logs")); /** * LogsRetrieve class extending the superClass Logs. */ class LogsRetrieve extends logs_1.default { async run() { /** * @param object * Get flags value. */ const { flags } = this.parse(LogsRetrieve); /** * @param string * Api key value. */ const apiKey = flags['api-key']; /** * @param string * Environment type. */ const environment = flags.environment; /** * @param number * store the log id. */ const id = flags.id; /** * Set Apikey and environment to connect to fedapay. */ fedapay_1.FedaPay.setApiKey(apiKey); fedapay_1.FedaPay.setEnvironment(environment); try { cli_ux_1.cli.action.start('Retrieve log'); // Start the spiner. const log = await fedapay_1.Log.retrieve(id); this.log(json_colorizer_1.default(JSON.stringify(log, null, 2))); } catch (error) { this.error(chalk_1.default.red.italic(`${error.name} : ${error.message}`)); } cli_ux_1.cli.action.stop(); // Stop the spiner. } } exports.default = LogsRetrieve; /** * @param string * Description of the command logs:retrieve. */ LogsRetrieve.description = 'Retrieve a log'; /** * @param string * Custom usage string for help * This overrides the default usage */ LogsRetrieve.usage = 'logs:retrieve [parameters...]'; /** * @param object * Declaration of the command flags. */ LogsRetrieve.flags = Object.assign(Object.assign({}, logs_1.default.flags), { id: command_1.flags.string({ description: 'ID of the log.', required: true, }), help: command_1.flags.help({ char: 'h', description: 'Help for logs:retrieve command.' }) }); /** * @param string[] * Some examples of the logs retrieve use for help. */ LogsRetrieve.examples = [ 'logs:retrieve --api-key=[API_KEY] --environment=sandbox --id=ID', 'logs:retrieve --api-key=[API_KEY] --environment=sandbox --id=ID', ];