"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const mablApiClientFactory_1 = require("@mablhq-internal/runtime/api/mablApiClientFactory");
const cliUtil_1 = require("@mablhq-internal/runtime/core/cliUtil");
const commandTypes_1 = require("@mablhq-internal/runtime/core/commandTypes");
const list_1 = require("../../commandUtil/list");
const constants_1 = require("../../constants");
const constants_2 = require("@mablhq-internal/runtime/core/constants");
exports.command = `scenarios <${constants_2.CommandArgId}>`;
exports.describe = 'List the scenarios of a datatable';
exports.builder = (yargs) => {
    yargs
        .option(constants_1.CommandArgLimitOutput, {
        alias: constants_1.CommandArgAliases.LimitOutput,
        describe: `The number of scenarios to return'`,
        default: commandTypes_1.DEFAULT_LISTING_RESULT_LIMIT,
        nargs: 1,
        type: 'string',
    })
        .option(constants_1.CommandArgOutput, {
        alias: constants_1.CommandArgAliases.OutputType,
        choices: constants_1.DefaultOutputFormatChoices,
        describe: 'Specify result output format',
        nargs: 1,
    });
};
exports.handler = (0, cliUtil_1.failWrapper)(dataTableScenarios);
async function dataTableScenarios(parsed) {
    const output = parsed.output;
    const dataTableId = parsed.id;
    const limit = parsed.limit;
    const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
    const queryResult = await apiClient.queryScenarios(dataTableId, limit);
    (0, list_1.outputEntities)(queryResult.scenarios ?? [], output);
}
