Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Console/Commands/Node/NodeConfigurationCommand.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 NodeConfigurationCommand extends Command
9
{
10
protected $signature = 'p:node:configuration
11
{node : The ID or UUID of the node to return the configuration for.}
12
{--format=yaml : The output format. Options are "yaml" and "json".}';
13
14
protected $description = 'Displays the configuration for the specified node.';
15
16
public function handle(): int
17
{
18
$column = ctype_digit((string) $this->argument('node')) ? 'id' : 'uuid';
19
20
/** @var Node $node */
21
$node = Node::query()->where($column, $this->argument('node'))->firstOr(function () {
22
$this->error('The selected node does not exist.');
23
24
exit(1);
25
});
26
27
$format = $this->option('format');
28
if (!in_array($format, ['yaml', 'yml', 'json'])) {
29
$this->error('Invalid format specified. Valid options are "yaml" and "json".');
30
31
return 1;
32
}
33
34
if ($format === 'json') {
35
$this->output->write($node->getJsonConfiguration(true));
36
} else {
37
$this->output->write($node->getYamlConfiguration());
38
}
39
40
$this->output->newLine();
41
42
return 0;
43
}
44
}
45
46