"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cliConfigProvider_1 = require("@mablhq-internal/runtime/providers/cliConfigProvider");
const set_1 = require("./set");
const configKeys_1 = require("@mablhq-internal/runtime/providers/configKeys");
const list_1 = require("./list");
const loggingProvider_1 = require("@mablhq-internal/runtime/providers/logging/loggingProvider");
exports.command = `delete <${set_1.configKeyCommandArg}>`;
exports.describe = 'Delete a config value';
exports.builder = (yargs) => {
    yargs.positional(set_1.configKeyCommandArg, {
        describe: 'configuration key to delete',
        type: 'string',
        choices: configKeys_1.validConfigKeyChoices,
    });
};
exports.handler = deleteConfig;
async function deleteConfig(parsed) {
    const key = parsed['config-key'];
    switch (key) {
        case configKeys_1.configKeys.defaultWorkspaceId:
            await cliConfigProvider_1.CliConfigProvider.clearWorkspace();
            break;
        default:
            await cliConfigProvider_1.CliConfigProvider.clearConfigProperty(key);
    }
    loggingProvider_1.logger.info(`Deleted config for [${key}]`);
    return (0, list_1.listConfig)();
}
