import { Command, Flags } from '@oclif/core';
import chalk from 'chalk';
import { loadConfig } from '../../deploy/domain/config.js';
export default class List extends Command {
    static description = 'List configured bounded contexts for Google Sheets sync.';
    static examples = [
        '<%= config.bin %> sheets list',
    ];
    static flags = {
        config: Flags.string({
            char: 'c',
            default: './aurora.yaml',
            description: 'Path to aurora.yaml config file',
        }),
    };
    async run() {
        const { flags } = await this.parse(List);
        const config = loadConfig(flags.config);
        if (!config.sheets) {
            this.error('No "sheets" section found in aurora.yaml.\n' +
                'Add a sheets.bounded_contexts block to your config.');
        }
        const bcs = config.sheets.boundedContexts;
        const names = Object.keys(bcs);
        if (names.length === 0) {
            this.error('No bounded contexts configured in sheets section.');
        }
        this.log('Configured bounded contexts:\n');
        for (const name of names) {
            const bc = bcs[name];
            this.log(`  ${chalk.bold(name)}`);
            this.log(`    Spreadsheet ID: ${bc.spreadsheetId}`);
            if (bc.description) {
                this.log(`    Description: ${bc.description}`);
            }
            this.log('');
        }
    }
}
