UNPKG

@shipengine/connect

Version:

The official developer tooling for building ShipEngine connect apps

59 lines 2.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const command_1 = require("@oclif/command"); const chalk_1 = tslib_1.__importDefault(require("chalk")); const cli_table_1 = tslib_1.__importDefault(require("cli-table")); const base_app_command_1 = tslib_1.__importDefault(require("../../base-app-command")); class List extends base_app_command_1.default { static description = 'List environment variables for an app'; static flags = { ...base_app_command_1.default.flags, help: command_1.flags.help({ char: 'h', description: 'show help for the env command', }), format: command_1.flags.string({ char: 'f', description: 'specify output format', default: 'table', options: ['table', 'dotenv'], parse: (input) => input.toLowerCase(), }), }; async run() { if (!(this.client && this.platformApp)) { this.error('Initialization failed - invalid state'); return; } try { const configurationKeys = await this.client.configuration.list(this.platformApp.id); if (!(configurationKeys && configurationKeys.length > 0)) { this.log(`${this.platformApp.name} has no environment variables set`); return; } const { flags } = this.parse(List); if (flags.format === 'table') { const table = new cli_table_1.default({ head: [chalk_1.default.green('Name'), chalk_1.default.green('Value')], }); configurationKeys.forEach((key) => { table.push([key.name, key.value]); }); this.log(table.toString()); } else if (flags.format === 'dotenv') { configurationKeys.forEach((key) => { this.log(`${key.name}=${key.value}`); }); } } catch (error) { return this.error('Error retrieving environment variables', { exit: 1, }); } } } exports.default = List; //# sourceMappingURL=list.js.map