"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 backup_client_1 = require("../../../lib/backup-client");
const context_banner_1 = require("../../../lib/context-banner");
class BackupRestoreShow extends core_1.Command {
    async run() {
        const { args, flags } = await this.parse(BackupRestoreShow);
        (0, context_banner_1.printContextBanner)();
        const client = backup_client_1.BackupClient.fromConfig();
        const r = await client.getRestore(args.id);
        if (flags.json) {
            this.log(JSON.stringify(r, null, 2));
            return;
        }
        this.log('');
        this.log(`   ${chalk_1.default.bold('ID:')}         ${r.id}`);
        this.log(`   ${chalk_1.default.bold('Status:')}     ${r.status}`);
        this.log(`   ${chalk_1.default.bold('Artifact:')}   ${r.artifactId}`);
        this.log(`   ${chalk_1.default.bold('Source:')}     ${r.sourceDestinationId}`);
        this.log(`   ${chalk_1.default.bold('Target:')}     ${r.targetKind} → cluster=${r.targetClusterId}`);
        if (r.strategy)
            this.log(`   ${chalk_1.default.bold('Strategy:')}   ${r.strategy}`);
        if (r.startedAt)
            this.log(`   ${chalk_1.default.bold('Started:')}    ${r.startedAt}`);
        if (r.completedAt)
            this.log(`   ${chalk_1.default.bold('Completed:')}  ${r.completedAt}`);
        if (r.errorMessage)
            this.log(chalk_1.default.red(`   ${chalk_1.default.bold('Error:')}      ${r.errorMessage}`));
        this.log('');
    }
}
BackupRestoreShow.description = 'Show a restore job by ID';
BackupRestoreShow.args = { id: core_1.Args.string({ required: true }) };
BackupRestoreShow.flags = { json: core_1.Flags.boolean({ default: false }) };
exports.default = BackupRestoreShow;
