"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const command_base_enterprise_1 = require("../command-base-enterprise");
const user_context_loader_1 = require("../user-context-loader");
class Logout extends command_base_enterprise_1.CommandBaseEnterprise {
    run() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            try {
                this.bootstrap();
                const { args, flags } = yield this.parse(Logout);
                if (this._userCntx) {
                    let userName = this._userCntx.userName;
                    let tenantCode = this._userCntx.currentTenantCode;
                    let userContextLoader = new user_context_loader_1.UserContextLoader(this.cliEnviro, this.logger);
                    yield userContextLoader.clearUserContext();
                    this._ui.userMessage(`Successfully logged out user ${userName}.`);
                }
                else {
                    this._ui.userMessage("Nothing to do: user is already logged out.");
                }
                return;
            }
            catch (err) {
                throw err;
            }
            finally {
                yield this.closeConnections();
            }
        });
    }
}
exports.default = Logout;
Logout.description = 'Resets the current user to anonymous and clears any local user cache.';
Logout.examples = [
    '<%= config.bin %> <%= command.id %>',
];
Logout.flags = {};
Logout.args = {};
//# sourceMappingURL=logout.js.map