"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const cli_ux_1 = require("cli-ux");
const cli_tools_1 = require("@codiac.io/cli-tools");
const command_base_tenantless_1 = require("../../command-base-tenantless");
class IdentityList extends command_base_tenantless_1.CommandBaseTenantless {
    run() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            this.bootstrap();
            const { args, flags } = yield this.parse(IdentityList);
            let set = this._projUserCfg.identitySet;
            if (set) {
                if (flags.output == "json") {
                    this._ui.userMessage(JSON.stringify(set, undefined, 2));
                }
                else {
                    cli_ux_1.cli.table((0, cli_tools_1.toArray)(set), {
                        "name (aka: arg)": { get: row => row.tokenName },
                        provider: { extended: true },
                        registryUrl: { extended: true },
                        scope: { extended: true },
                        token: {}
                    }, { extended: (flags.output == "extended"), csv: (flags.output == "csv") });
                }
            }
            else {
                this.logger.notice(`No identity tokens are currently being held.`);
                this._ui.userMessage(`No identity tokens are currently being held.`);
            }
        });
    }
}
exports.default = IdentityList;
IdentityList.description = 'Lists out the identity tokens currently stored for the current user.';
IdentityList.aliases = ['token:list'];
IdentityList.flags = {
    help: core_1.Flags.help({ char: 'h', description: 'Displays the help document for this command.' }),
    output: core_1.Flags.string({ char: 'o', options: ['table', 'extended', 'json', 'csv'], default: 'table', description: "Format for the response data." })
};
IdentityList.args = {};
//# sourceMappingURL=list.js.map