/**
 * @license
 * Copyright 2025 HopCode Team
 * SPDX-License-Identifier: Apache-2.0
 */
import { getErrorMessage } from '../../utils/errors.js';
import { writeStdoutLine, writeStderrLine } from '../../utils/stdioHelpers.js';
import { extensionToOutputString, getExtensionManager } from './utils.js';
import { t } from '../../i18n/index.js';
export async function handleList() {
    try {
        const extensionManager = await getExtensionManager();
        const extensions = extensionManager.getLoadedExtensions();
        if (!extensions || extensions.length === 0) {
            writeStdoutLine(t('No extensions installed.'));
            return;
        }
        writeStdoutLine(extensions
            .map((extension, _) => extensionToOutputString(extension, extensionManager, process.cwd()))
            .join('\n\n'));
    }
    catch (error) {
        writeStderrLine(getErrorMessage(error));
        process.exit(1);
    }
}
export const listCommand = {
    command: 'list',
    describe: t('Lists installed extensions.'),
    builder: (yargs) => yargs,
    handler: async () => {
        await handleList();
    },
};
//# sourceMappingURL=list.js.map