"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 Status 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(Status);
                    let doAll = ((flags.staged && flags.unstaged) || (!flags.staged && !flags.unstaged));
                    if (flags.staged || doAll) {
                        let staged = yield this._ops.gitListChanges("staged");
                        this.renderChanges("staged", staged);
                    }
                    if (flags.unstaged || doAll) {
                        let unstaged = yield this._ops.gitListChanges("unstaged");
                        this.renderChanges("unstaged", unstaged);
                    }
                    resolve();
                }
                catch (err) {
                    this.handleError(err);
                    reject(err);
                }
            }));
        });
    }
    renderChanges(index, changes) {
        this._ui.userMessage(`${index} changes:`);
        if (changes.length > 0) {
            changes.forEach(c => this._ui.userMessage(`\t${c}`));
        }
        else {
            this._ui.userMessage(`\tNone.`);
        }
    }
}
exports.default = Status;
Status.description = 'Shows the current uncommitted changes in the current branch.';
Status.flags = {
    help: core_1.Flags.help({ char: 'h' }),
    staged: core_1.Flags.boolean({ char: "s", description: "Include the list of staged changes." }),
    unstaged: core_1.Flags.boolean({ char: "u", description: "Include the list of unstaged changes." })
};
Status.args = {};
//# sourceMappingURL=status.js.map