"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.AlertAction = void 0;
const BaseRushAction_1 = require("./BaseRushAction");
const RushAlerts_1 = require("../../utilities/RushAlerts");
class AlertAction extends BaseRushAction_1.BaseRushAction {
    constructor(parser) {
        super({
            actionName: 'alert',
            summary: '(EXPERIMENTAL) View and manage Rush alerts for the repository',
            documentation: 'This command displays the Rush alerts for this repository.  Rush alerts are customizable announcements' +
                ' and reminders that Rush prints occasionally on the command line.' +
                '  The alert definitions can be found in the rush-alerts.json config file.',
            parser
        });
        this._snoozeParameter = this.defineStringParameter({
            parameterLongName: '--snooze',
            parameterShortName: '-s',
            argumentName: 'ALERT_ID',
            description: 'Temporarily suspend the specified alert for one week'
        });
        this._snoozeTimeFlagParameter = this.defineFlagParameter({
            parameterLongName: '--forever',
            description: 'Combined with "--snooze", causes that alert to be suspended permanently'
        });
    }
    async runAsync() {
        const rushAlerts = await RushAlerts_1.RushAlerts.loadFromConfigurationAsync(this.rushConfiguration, this.terminal);
        const snoozeAlertId = this._snoozeParameter.value;
        if (snoozeAlertId) {
            const snoozeTimeFlag = this._snoozeTimeFlagParameter.value;
            await rushAlerts.snoozeAlertsByAlertIdAsync(snoozeAlertId, snoozeTimeFlag);
        }
        await rushAlerts.printAllAlertsAsync();
    }
}
exports.AlertAction = AlertAction;
//# sourceMappingURL=AlertAction.js.map