Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Console/Commands/Node/NodeListCommand.php
7460 views
1
<?php
2
3
namespace Pterodactyl\Console\Commands\Node;
4
5
use Pterodactyl\Models\Node;
6
use Illuminate\Console\Command;
7
8
class NodeListCommand extends Command
9
{
10
protected $signature = 'p:node:list {--format=text : The output format: "text" or "json". }';
11
12
public function handle(): int
13
{
14
$nodes = Node::query()->with('location')->get()->map(function (Node $node) {
15
return [
16
'id' => $node->id,
17
'uuid' => $node->uuid,
18
'name' => $node->name,
19
'location' => $node->location->short,
20
'host' => $node->getConnectionAddress(),
21
];
22
});
23
24
if ($this->option('format') === 'json') {
25
$this->output->write($nodes->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
26
} else {
27
$this->table(['ID', 'UUID', 'Name', 'Location', 'Host'], $nodes->toArray());
28
}
29
30
$this->output->newLine();
31
32
return 0;
33
}
34
}
35
36