Path: blob/1.0-develop/app/Console/Commands/Node/NodeConfigurationCommand.php
7460 views
<?php12namespace Pterodactyl\Console\Commands\Node;34use Pterodactyl\Models\Node;5use Illuminate\Console\Command;67class NodeConfigurationCommand extends Command8{9protected $signature = 'p:node:configuration10{node : The ID or UUID of the node to return the configuration for.}11{--format=yaml : The output format. Options are "yaml" and "json".}';1213protected $description = 'Displays the configuration for the specified node.';1415public function handle(): int16{17$column = ctype_digit((string) $this->argument('node')) ? 'id' : 'uuid';1819/** @var Node $node */20$node = Node::query()->where($column, $this->argument('node'))->firstOr(function () {21$this->error('The selected node does not exist.');2223exit(1);24});2526$format = $this->option('format');27if (!in_array($format, ['yaml', 'yml', 'json'])) {28$this->error('Invalid format specified. Valid options are "yaml" and "json".');2930return 1;31}3233if ($format === 'json') {34$this->output->write($node->getJsonConfiguration(true));35} else {36$this->output->write($node->getYamlConfiguration());37}3839$this->output->newLine();4041return 0;42}43}444546