import { requireString, requireStringList } from '../args.js';
import { createContext } from '../context.js';
import { CliError } from '../errors.js';
import { writeOutput } from '../output.js';
import { normalizeEntityType } from '../type-validation.js';
import { withMeta } from './_meta.js';
export function runElementList(args) {
    const type = normalizeEntityType(requireString(args, 'type'));
    const slugs = requireStringList(args, 'slugs');
    const ctx = createContext(args);
    try {
        const { items: entities, missing } = ctx.reader.getEntities(type, slugs);
        if (entities.length === 0) {
            throw new CliError('ENTITY_NOT_FOUND', `no ${type} found for slugs: ${slugs.join(', ')}`);
        }
        const items = entities.map((entity) => withMeta(ctx.registry.serializeEntity(type, 'element_list_item', entity, ctx.reader)));
        writeOutput({ items, missing }, args);
    }
    finally {
        ctx.close();
    }
}
//# sourceMappingURL=element-list.js.map