"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mablApiClientFactory_1 = require("@mablhq-internal/runtime/api/mablApiClientFactory");
const describe_1 = require("../../commandUtil/describe");
const util_1 = require("../../commandUtil/util");
const cliUtil_1 = require("@mablhq-internal/runtime/core/cliUtil");
const constants_1 = require("../../constants");
exports.command = 'describe <id>';
exports.describe = (0, util_1.getDescribeDescriptions)('environment');
exports.builder = {
    [constants_1.CommandArgDecrypt]: {
        describe: `Set to decrypt and return environment variables as part of the payload`,
        boolean: true,
    },
    ...(0, describe_1.getDescribeBuilderOptions)(),
};
exports.handler = (0, cliUtil_1.failWrapper)(getEnvironment);
async function getEnvironment(parsed) {
    try {
        const environmentId = parsed.id;
        const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
        const environment = await apiClient.getEnvironment(environmentId, parsed.decrypt);
        (0, describe_1.outputEntity)(environment, parsed.output);
        return environment.id;
    }
    catch (error) {
        throw new Error(`Error getting environment: ${error}`);
    }
}
