<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Console\Commands;

use PpPhp\Core\Platform\Console\AbstractCommand;

final class DistributedFailoverActionsCommand extends AbstractCommand
{
    public function name(): string { return 'distributed:failover:actions'; }
    public function description(): string { return 'PPphp Distributed Failover Actions'; }

    public function handle(array $arguments = []): int
    {
        $this->title('PPphp Distributed Failover Actions');
        $summary = \PpPhp\Core\Platform\Event\Distributed\Failover\DistributedFailoverManager::instance(\PpPhp\Core\Platform\Console\ConsolePath::basePath())->summary(); foreach ($summary['actions'] as $action) { $this->line('- ' . $action['action'] . ' target=' . $action['target'] . ' success=' . ($action['successful'] ? 'YES' : 'NO')); }
        return 0;
    }
}
