"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("@oclif/command");
const command_2 = __importDefault(require("../extends/command"));
const account_1 = __importDefault(require("../implements/account"));
const env_1 = require("../utils/env");
class Logout extends command_2.default {
    run() {
        return __awaiter(this, void 0, void 0, function* () {
            const { flags } = this.parse(Logout);
            const account = new account_1.default();
            account.eventTracker('logout_start', { tags: Object.assign({}, flags) });
            account_1.default.checkTokenExist(this.id);
            const isLogin = account.isLogin();
            if (isLogin) {
                yield account.logout({ environment: flags.environment });
                console.info(this.success('Success') + ' log out');
            }
            else {
                console.log('Not login in this environment');
            }
        });
    }
}
exports.default = Logout;
Logout.description = 'Log out of the Feishu account';
Logout.flags = {
    environment: command_1.flags.enum({
        char: 'e',
        description: 'environment',
        options: env_1.environment,
    }),
    help: command_1.flags.help({
        char: 'h',
    }),
};
