Files
pterodactyl-panel/app/Console/Commands/Node/NodeListCommand.php
T

35 lines
974 B
PHP
Raw Normal View History

<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
namespace Pterodactyl\Console\Commands\Node;
2026-10-05 18:10:18 -04:00
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Models\Node;
2026-10-05 18:10:18 -04:00
#[Signature('p:node:list {--format=text : The output format: "text" or "json". }')]
class NodeListCommand extends Command
{
2022-10-14 10:59:20 -06:00
public function handle(): int
{
2026-10-05 18:10:18 -04:00
$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 {
2026-10-05 18:10:18 -04:00
$this->table(['ID', 'UUID', 'Name', 'Location', 'Host'], $nodes->all());
}
$this->output->newLine();
return 0;
}
}