UNPKG

salesforce-alm

Version:

This package contains tools, and APIs, for an improved salesforce.com developer experience.

54 lines (52 loc) 1.82 kB
"use strict"; /* * Copyright (c) 2020, salesforce.com, inc. * All rights reserved. * Licensed under the BSD 3-Clause license. * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ const orgSnapshotApi_1 = require("./orgSnapshotApi"); const Messages = require("../../messages"); const messages = Messages(); const logger = require("../../core/logApi"); /** * Get a Org Snapshot record. */ class OrgSnapshotGetCommand { constructor() { this.logger = logger.child('org:snapshot:get'); } execute(context) { // double-check if (!context.flags.snapshot) { throw new Error(messages.getMessage('snapshotInvalid', [], 'orgSnapshot')); } this.orgSnapshotIdOrName = context.flags.snapshot; return orgSnapshotApi_1.OrgSnapshotApiImpl.create(context.org).then((orgSnapshotApi) => { this.orgSnapshotApi = orgSnapshotApi; return this.orgSnapshotApi.get(this.orgSnapshotIdOrName); }); } /** * returns a human readable message for a cli output * * @param result - the data representing the Org Snapshot * @returns {string} */ getHumanSuccessMessage(result) { const data = this.orgSnapshotApi.mapDataToLabel(result); if (result.Status === 'Error') { data.push({ name: 'Error', value: result.Error || 'Unknown' }); } this.logger.styledHeader(this.logger.color.blue('Org Snapshot')); this.logger.table(data, { columns: [ { key: 'name', label: 'Name' }, { key: 'value', label: 'Value' }, ], }); return ''; } } module.exports = OrgSnapshotGetCommand; //# sourceMappingURL=orgSnapshotGetCommand.js.map