<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class QueryRegisterCommand extends AbstractCommand
{
    public function name(): string { return 'query:register'; }
    public function description(): string { return 'PPphp Query Register'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Query Register');
        $definition = \PpPhp\Core\Platform\Event\Sourcing\Query\QueryRuntime::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath())->register(\PpPhp\Core\Platform\Event\Sourcing\Query\ReadModelDefinition::create('console_read_model', 'console_projection', 'Console Read Model', ['aggregateId', 'state'])); $this->line('Registered: ' . $definition->readModelId());
        return 0;
    }
}
