import { Command, flags } from '@heroku-cli/command';
import * as color from '@heroku/heroku-cli-util/color';
import { Args } from '@oclif/core';
import { getPipeline } from '../../lib/ci/pipelines.js';
import { displayTestRunInfo } from '../../lib/ci/test-run.js';
export default class CiInfo extends Command {
    static args = {
        'test-run': Args.string({ description: 'auto-incremented test run number', required: true }),
    };
    static description = 'show the status of a specific test run';
    static examples = [
        color.command(`heroku ci:info 1288 --app murmuring-headland-14719
`),
    ];
    static flags = {
        app: flags.app(),
        node: flags.string({ description: 'the node number to show its setup and output', required: false }),
        pipeline: flags.pipeline({ required: false }),
        remote: flags.remote(),
    };
    async run() {
        const { args, flags } = await this.parse(CiInfo);
        const pipeline = await getPipeline(flags, this.heroku);
        const { body: testRun } = await this.heroku.get(`/pipelines/${pipeline.id}/test-runs/${args['test-run']}`);
        const { body: testNodes } = await this.heroku.get(`/test-runs/${testRun.id}/test-nodes`);
        await displayTestRunInfo(this, testRun, testNodes, flags.node);
    }
}
