"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const core_1 = require("@oclif/core");
const command_base_tenantless_1 = require("../../command-base-tenantless");
class BranchList 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(BranchList);
            let includeRemotes = flags.remotes || (flags.locals == false);
            let includeLocals = flags.locals || (flags.remotes == false);
            let branches = yield this._ops.gitListBranches(includeRemotes, includeLocals);
            if (branches.length > 0) {
                // if (flags.output == "json") {
                //   this._ui.userMessage(JSON.stringify(set, undefined, 2));
                // } else {
                // cli.table(branches.map(b => { return { branch: b }; }), {
                //   branch: {}
                // });  //, { extended: (flags.output == "extended"), csv: (flags.output == "csv") });
                // }
                this._ui.userMessage(this._styler.bold("Branches\n------------------------------------"));
                for (let branch of branches) {
                    this._ui.userMessage(branch);
                }
            }
            else {
                let locations = [];
                if (flags.locals)
                    locations.push("local");
                if (flags.remotes)
                    locations.push("remote");
                this.logger.notice(`No ${locations.join(" or ")} branches were found.`);
                this._ui.userMessage(`No ${locations.join(" or ")} branches were found.`);
            }
        });
    }
    toArray(dictionary) {
        let output = [];
        for (let key in dictionary) {
            output.push(dictionary[key]);
        }
        return output;
    }
}
exports.default = BranchList;
BranchList.description = 'Lists out existing branches for the project repo.';
BranchList.aliases = ['branches:list'];
BranchList.flags = {
    help: core_1.Flags.help({ char: 'h', description: 'Displays the help document for this command.' }),
    // output: Flags.custom({char: 'o', options: [ 'table', 'extended', 'json', 'csv' ], default: 'table', description: "Format for the response data."}),
    remotes: core_1.Flags.boolean({ char: 'r', default: false, exclusive: ["locals"], description: "(Optional, defaults to false) Limits to remote branches only." }),
    locals: core_1.Flags.boolean({ char: 'l', default: false, exclusive: ["remotes"], description: "(Optional, defaults to false) Limits to local branches only." })
};
BranchList.args = {};
//# sourceMappingURL=list.js.map