"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const BaseCommand_1 = require("../../BaseCommand");
const core_1 = require("@oclif/core");
class ListMoveAllCards extends BaseCommand_1.BaseCommand {
    constructor() {
        super(...arguments);
        this.defaultOutput = "fancy";
    }
    async run() {
        const destinationBoardId = await this.cache.getBoardIdByName(this.flags["destination-board"]);
        const destinationListId = await this.cache.getListIdByBoardAndName(destinationBoardId, this.flags["destination-list"]);
        const result = await this.client.lists.moveAllCardsInList({
            id: this.lookups.list,
            idBoard: destinationBoardId,
            idList: destinationListId,
        });
        this.output(result);
    }
    toData(data) {
        if (!Array.isArray(data)) {
            return [];
        }
        return data.map((card) => ({
            id: card.id,
            name: card.name,
        }));
    }
    async format(data) {
        if (!Array.isArray(data) || data.length === 0) {
            return "No cards moved";
        }
        return `${data.length} ${data.length === 1 ? "card" : "cards"} moved`;
    }
}
ListMoveAllCards.description = "Move all cards from one list to another";
ListMoveAllCards.flags = {
    board: core_1.Flags.string({
        required: true,
        description: "The board containing the source list",
    }),
    list: core_1.Flags.string({
        required: true,
        description: "The source list containing the cards to move",
    }),
    "destination-board": core_1.Flags.string({
        required: true,
        description: "The destination board",
    }),
    "destination-list": core_1.Flags.string({
        required: true,
        description: "The destination list",
    }),
};
exports.default = ListMoveAllCards;
