"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const BaseCommand_1 = require("../../BaseCommand");
const core_1 = require("@oclif/core");
class CardComments extends BaseCommand_1.BaseCommand {
    constructor() {
        super(...arguments);
        this.defaultOutput = "fancy";
    }
    async run() {
        const actions = await this.client.cards.getCardActions({
            id: this.lookups.card,
            filter: "commentCard",
        });
        this.output(actions);
    }
    toData(data) {
        return data.map((action) => ({
            id: action.id,
            text: action.data.text,
            author: action.memberCreator.fullName,
            date: action.date,
        }));
    }
    async format(data) {
        if (data.length === 0) {
            return "No comments";
        }
        return data
            .map((c) => `${c.author} [${c.date}]: ${c.text}`)
            .join("\n");
    }
}
CardComments.description = "List comments on a card";
CardComments.flags = {
    board: core_1.Flags.string({ required: true }),
    list: core_1.Flags.string({ required: true }),
    card: core_1.Flags.string({ required: true }),
};
exports.default = CardComments;
