Skip to content

Commit 3f47d7a

Browse files
committed
Allow returning the node configuration from the CLI; closes pterodactyl#4047
1 parent 100d4ee commit 3f47d7a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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()
17+
{
18+
/** @var \Pterodactyl\Models\Node $node */
19+
$node = Node::query()->findOrFail($this->argument('node'));
20+
21+
$format = $this->option('format');
22+
if (!in_array($format, ['yaml', 'yml', 'json'])) {
23+
$this->error('Invalid format specified. Valid options are "yaml" and "json".');
24+
25+
return 1;
26+
}
27+
28+
if ($format === 'json') {
29+
$this->output->write($node->getJsonConfiguration(true));
30+
} else {
31+
$this->output->write($node->getYamlConfiguration());
32+
}
33+
34+
$this->output->newLine();
35+
36+
return 0;
37+
}
38+
}

0 commit comments

Comments
 (0)