"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const chalk_1 = __importDefault(require("chalk"));
const ora_1 = __importDefault(require("ora"));
const backup_client_1 = require("../../../lib/backup-client");
const context_banner_1 = require("../../../lib/context-banner");
class BackupJobRun extends core_1.Command {
    async run() {
        const { flags } = await this.parse(BackupJobRun);
        (0, context_banner_1.printContextBanner)();
        const client = backup_client_1.BackupClient.fromConfig();
        const spinner = (0, ora_1.default)('Queuing backup job...').start();
        try {
            const job = await client.runJobForPolicy(flags.policy);
            spinner.succeed(`Queued job ${chalk_1.default.cyan(job.id)} (status=${job.status})`);
            this.log(chalk_1.default.dim(`   Track with: flui backup job show ${job.id}`));
        }
        catch (err) {
            spinner.fail(`Run failed: ${err.message}`);
            this.exit(1);
        }
    }
}
BackupJobRun.description = 'Trigger an on-demand backup job for a given policy';
BackupJobRun.flags = {
    policy: core_1.Flags.string({ required: true, description: 'Policy ID' }),
};
exports.default = BackupJobRun;
