"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const color_1 = require("@heroku-cli/color");
const command_1 = require("@heroku-cli/command");
const cli_ux_1 = require("cli-ux");
class DomainsClear extends command_1.Command {
    async run() {
        const { flags } = this.parse(DomainsClear);
        cli_ux_1.default.action.start(`Removing all domains from ${color_1.color.app(flags.app)}`);
        let { body: domains } = await this.heroku.get(`/apps/${flags.app}/domains`);
        domains = domains.filter((d) => d.kind === 'custom');
        for (const domain of domains) {
            // eslint-disable-next-line no-await-in-loop
            await this.heroku.delete(`/apps/${flags.app}/domains/${domain.hostname}`);
        }
        cli_ux_1.default.action.stop();
    }
}
exports.default = DomainsClear;
DomainsClear.description = 'remove all domains from an app';
DomainsClear.examples = ['heroku domains:clear'];
DomainsClear.flags = {
    help: command_1.flags.help({ char: 'h' }),
    app: command_1.flags.app({ required: true }),
    remote: command_1.flags.remote(),
};
