import { Command, flags } from '@heroku-cli/command';
import * as color from '@heroku/heroku-cli-util/color';
import { getPipeline } from '../../lib/ci/pipelines.js';
import { renderList } from '../../lib/ci/test-run.js';
export default class CiIndex extends Command {
    static description = 'display the most recent CI runs for the given pipeline';
    static examples = [
        color.command(`heroku ci --app murmuring-headland-14719
`),
    ];
    static flags = {
        app: flags.app(),
        json: flags.boolean({ description: 'output in json format', required: false }),
        pipeline: flags.pipeline({ required: false }),
        remote: flags.remote(),
        watch: flags.boolean({ description: 'keep running and watch for new and update tests', required: false }),
    };
    async run() {
        const { flags } = await this.parse(CiIndex);
        const pipeline = await getPipeline(flags, this.heroku);
        const { body: testRuns } = await this.heroku.get(`/pipelines/${pipeline.id}/test-runs`);
        await renderList(this, testRuns, pipeline, flags.watch, flags.json);
    }
}
