Files
pterodactyl-panel/app/Console/Commands/Node/NodeListCommand.php
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

35 lines
974 B
PHP

<?php
declare(strict_types=1);
namespace Pterodactyl\Console\Commands\Node;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
use Pterodactyl\Models\Node;
#[Signature('p:node:list {--format=text : The output format: "text" or "json". }')]
class NodeListCommand extends Command
{
public function handle(): int
{
$nodes = Node::query()->with('location')->get()->map(fn (Node $node): array => [
'id' => $node->id,
'uuid' => $node->uuid,
'name' => $node->name,
'location' => $node->location->short,
'host' => $node->getConnectionAddress(),
]);
if ($this->option('format') === 'json') {
$this->output->write($nodes->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
} else {
$this->table(['ID', 'UUID', 'Name', 'Location', 'Host'], $nodes->all());
}
$this->output->newLine();
return 0;
}
}