Allow returning the node configuration from the CLI; closes pterodactyl/panel#4047
This commit is contained in:
		
							parent
							
								
									100d4ee726
								
							
						
					
					
						commit
						3f47d7a12c
					
				
							
								
								
									
										38
									
								
								app/Console/Commands/Node/NodeConfigurationCommand.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								app/Console/Commands/Node/NodeConfigurationCommand.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,38 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Pterodactyl\Console\Commands\Node; | ||||
| 
 | ||||
| use Pterodactyl\Models\Node; | ||||
| use Illuminate\Console\Command; | ||||
| 
 | ||||
| class NodeConfigurationCommand extends Command | ||||
| { | ||||
|     protected $signature = 'p:node:configuration | ||||
|                             {node : The ID or UUID of the node to return the configuration for.} | ||||
|                             {--format=yaml : The output format. Options are "yaml" and "json".}'; | ||||
| 
 | ||||
|     protected $description = 'Displays the configuration for the specified node.'; | ||||
| 
 | ||||
|     public function handle() | ||||
|     { | ||||
|         /** @var \Pterodactyl\Models\Node $node */ | ||||
|         $node = Node::query()->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; | ||||
|     } | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 DaneEveritt
						DaneEveritt