From 3f47d7a12c62849e3bf8e8b4edb6231a9068fafa Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Fri, 13 May 2022 21:30:16 -0400 Subject: [PATCH] Allow returning the node configuration from the CLI; closes pterodactyl/panel#4047 --- .../Node/NodeConfigurationCommand.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/Console/Commands/Node/NodeConfigurationCommand.php diff --git a/app/Console/Commands/Node/NodeConfigurationCommand.php b/app/Console/Commands/Node/NodeConfigurationCommand.php new file mode 100644 index 000000000..7cb31ba9a --- /dev/null +++ b/app/Console/Commands/Node/NodeConfigurationCommand.php @@ -0,0 +1,38 @@ +findOrFail($this->argument('node')); + + $format = $this->option('format'); + if (!in_array($format, ['yaml', 'yml', 'json'])) { + $this->error('Invalid format specified. Valid options are "yaml" and "json".'); + + return 1; + } + + if ($format === 'json') { + $this->output->write($node->getJsonConfiguration(true)); + } else { + $this->output->write($node->getYamlConfiguration()); + } + + $this->output->newLine(); + + return 0; + } +}