"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.stepsCommand = void 0;
const debugCommands_1 = require("../debugCommands");
const debugUtils_1 = require("./util/debugUtils");
const debugFailWrapper_1 = require("./util/debugFailWrapper");
const stepsHandler_1 = require("./util/stepsHandler");
const constants_1 = require("../../constants");
const constants_2 = require("@mablhq-internal/runtime/core/constants");
async function handleStepsCommand(args) {
    const id = args[constants_1.CommandArgId];
    (0, debugUtils_1.assertTestRunId)(id);
    await (0, stepsHandler_1.handleSteps)({
        testRunId: id,
        showAll: args[constants_1.CommandArgAll],
        outputFormat: args[constants_1.CommandArgOutput],
        apiKey: args[constants_1.CommandArgApiKey],
    });
}
exports.stepsCommand = (0, debugCommands_1.defineLeaf)({
    command: `steps <${constants_1.CommandArgId}>`,
    describe: 'Get the failed and recovered (by Runtime recovery) steps from a test run. Pass --all for the full trace.',
    builder: (yargs) => {
        yargs
            .positional(constants_1.CommandArgId, {
            type: 'string',
            describe: 'Test run ID, e.g. abc123-jr',
        })
            .option(constants_1.CommandArgAll, {
            describe: 'Emit every executed step instead of the failed/recovered subset. The summary block is unchanged.',
            type: 'boolean',
            default: false,
        })
            .option(constants_1.CommandArgOutput, {
            alias: constants_1.CommandArgAliases.OutputType,
            describe: 'Output format (json | yaml).',
            choices: constants_1.DefaultOutputFormatChoices,
            default: constants_2.OutputFormats.Yaml,
            nargs: 1,
        });
    },
    handler: (0, debugFailWrapper_1.debugFailWrapper)(handleStepsCommand),
});
