"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const BaseCommand_1 = require("../../BaseCommand");
const core_1 = require("@oclif/core");
class BoardCreate extends BaseCommand_1.BaseCommand {
    async run() {
        const board = await this.client.boards.createBoard({
            name: this.flags.name,
            desc: this.flags.description,
            defaultLists: this.flags.defaultLists, // Add them by default
            idOrganization: this.flags.org,
            prefs: {
                cardAging: this.flags["prefs.cardAging"],
                cardCovers: this.flags["prefs.cardCovers"],
                permissionLevel: this.flags["prefs.permissionLevel"],
                selfJoin: this.flags["prefs.selfJoin"],
            },
        });
        // Sync after adding a new board
        await this.cache.sync();
        this.output(board);
    }
    toData(data) {
        return {
            id: data.id,
            name: data.name,
            desc: data.desc,
            url: data.url,
        };
    }
}
BoardCreate.description = "Create a board";
BoardCreate.flags = {
    name: core_1.Flags.string({ char: "n", required: true }),
    description: core_1.Flags.string({ char: "d" }),
    org: core_1.Flags.string({
        description: "The id or name of the Workspace the board should belong to.",
    }),
    "prefs.permissionLevel": core_1.Flags.option({
        options: ["org", "private", "public"],
    })(),
    "prefs.cardAging": core_1.Flags.option({ options: ["regular", "pirate"] })(),
    "prefs.cardCovers": core_1.Flags.boolean({
        description: "Whether card covers should be displayed on this board",
    }),
    "prefs.selfJoin": core_1.Flags.boolean({
        description: "Determines whether users can join the boards themselves or whether they have to be invited.",
    }),
    defaultLists: core_1.Flags.boolean({ "default": true }),
};
exports.default = BoardCreate;
