"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const BaseCommand_1 = require("../../BaseCommand");
const core_1 = require("@oclif/core");
class BoardUpdate extends BaseCommand_1.BaseCommand {
    async run() {
        const updates = { id: this.lookups.board };
        if (this.flags.name)
            updates.name = this.flags.name;
        if (this.flags.description !== undefined)
            updates.desc = this.flags.description;
        if (Object.keys(updates).length <= 1) {
            this.warn("No update flags provided. Use --name or --description.");
            this.exit(1);
        }
        const board = await this.client.boards.updateBoard(updates);
        await this.cache.sync();
        this.output(board);
    }
    toData(data) {
        return {
            id: data.id,
            name: data.name,
            desc: data.desc,
            url: data.url,
            closed: data.closed,
        };
    }
}
BoardUpdate.description = "Update a board";
BoardUpdate.flags = {
    board: core_1.Flags.string({ required: true }),
    name: core_1.Flags.string({ char: "n" }),
    description: core_1.Flags.string(),
};
exports.default = BoardUpdate;
