"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 Branch extends command_base_tenantless_1.CommandBaseTenantless {
    run() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => tslib_1.__awaiter(this, void 0, void 0, function* () {
                try {
                    this.bootstrap();
                    const { args, flags } = yield this.parse(Branch);
                    if (!args.name) {
                        throw new Error("Operation cancelled: You must specify the name of the branch to create.  No work was done.");
                    }
                    else {
                        let branch = args.name;
                        yield this._ops.gitCreateBranch(branch);
                        if (flags.switch == true) {
                            yield this._ops.gitSwitchToBranch(branch);
                        }
                    }
                    resolve();
                }
                catch (err) {
                    this.handleError(err);
                    reject(err);
                }
            }));
        });
    }
}
exports.default = Branch;
Branch.description = 'Creates a new branch for the parent project and any sourced dependencies.';
Branch.flags = {
    switch: core_1.Flags.boolean({ char: 's', description: 'Automatically switches to the new branch after creating it.' }),
    help: core_1.Flags.help({ char: 'h' })
};
Branch.args = {
    name: core_1.Args.string({ description: 'The name of the branch to create.' })
};
//# sourceMappingURL=branch.js.map