<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class DistributedLeaseListCommand extends AbstractCommand
{
    public function name(): string { return 'distributed:lease:list'; }
    public function description(): string { return 'PPphp Distributed Job Lease List'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Distributed Job Lease List');
        $manager = \PpPhp\Core\Platform\Event\Distributed\Lease\DistributedLeaseManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath()); foreach ($manager->summary()['leases'] as $lease) { $this->line('- ' . $lease['leaseId'] . ' job=' . $lease['jobId'] . ' worker=' . $lease['nodeId'] . '/' . $lease['workerId'] . ' status=' . $lease['status']); }
        return 0;
    }
}
