"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 BackupJobShow extends core_1.Command {
    async run() {
        const { args, flags } = await this.parse(BackupJobShow);
        (0, context_banner_1.printContextBanner)();
        const client = backup_client_1.BackupClient.fromConfig();
        const j = await client.getJob(args.id);
        if (flags.json) {
            this.log(JSON.stringify(j, null, 2));
            return;
        }
        this.log('');
        this.log(`   ${chalk_1.default.bold('ID:')}        ${j.id}`);
        this.log(`   ${chalk_1.default.bold('Policy:')}    ${j.policyId}`);
        this.log(`   ${chalk_1.default.bold('Status:')}    ${j.status}`);
        if (j.startedAt)
            this.log(`   ${chalk_1.default.bold('Started:')}   ${j.startedAt}`);
        if (j.completedAt)
            this.log(`   ${chalk_1.default.bold('Completed:')} ${j.completedAt}`);
        if (j.bytesTransferred)
            this.log(`   ${chalk_1.default.bold('Bytes:')}     ${(j.bytesTransferred / 1024 ** 2).toFixed(2)} MB`);
        if (j.errorMessage)
            this.log(chalk_1.default.red(`   ${chalk_1.default.bold('Error:')}     ${j.errorMessage}`));
        this.log('');
    }
}
BackupJobShow.description = 'Show a backup job by ID';
BackupJobShow.args = { id: core_1.Args.string({ required: true }) };
BackupJobShow.flags = { json: core_1.Flags.boolean({ default: false }) };
exports.default = BackupJobShow;
