"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultTupleValue = void 0;
exports.listConfig = listConfig;
const cliConfigProvider_1 = require("@mablhq-internal/runtime/providers/cliConfigProvider");
const cli_table3_1 = __importDefault(require("cli-table3"));
const configKeys_1 = require("@mablhq-internal/runtime/providers/configKeys");
const loggingProvider_1 = require("@mablhq-internal/runtime/providers/logging/loggingProvider");
exports.command = `list`;
exports.describe = 'List all user config values';
exports.handler = listConfig;
exports.defaultTupleValue = '---';
async function listConfig() {
    const table = new cli_table3_1.default({
        head: ['Config', 'Value', 'Details'],
        colWidths: [null, 60],
    });
    for (const propertyKey of configKeys_1.validConfigKeyChoices) {
        let value;
        let details;
        switch (propertyKey) {
            case configKeys_1.configKeys.defaultWorkspaceId:
                const maybeWorkspace = await cliConfigProvider_1.CliConfigProvider.getWorkspace();
                value = maybeWorkspace?.id;
                details = maybeWorkspace?.name;
                break;
            default:
                value = await cliConfigProvider_1.CliConfigProvider.getConfigProperty(propertyKey);
        }
        const displayValue = value !== undefined ? value : exports.defaultTupleValue;
        const displayDetails = details !== undefined ? details : exports.defaultTupleValue;
        table.push([propertyKey, displayValue, displayDetails]);
    }
    loggingProvider_1.logger.info(table.toString());
    return table;
}
