mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 16:56:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			34 lines
		
	
	
		
			874 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			874 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Console\Commands\Node;
 | 
						|
 | 
						|
use App\Models\Node;
 | 
						|
use Illuminate\Console\Command;
 | 
						|
 | 
						|
class NodeListCommand extends Command
 | 
						|
{
 | 
						|
    protected $signature = 'p:node:list {--format=text : The output format: "text" or "json". }';
 | 
						|
 | 
						|
    public function handle(): int
 | 
						|
    {
 | 
						|
        $nodes = Node::query()->get()->map(function (Node $node) {
 | 
						|
            return [
 | 
						|
                'id' => $node->id,
 | 
						|
                'uuid' => $node->uuid,
 | 
						|
                'name' => $node->name,
 | 
						|
                'host' => $node->getConnectionAddress(),
 | 
						|
            ];
 | 
						|
        });
 | 
						|
 | 
						|
        if ($this->option('format') === 'json') {
 | 
						|
            $this->output->write($nodes->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
 | 
						|
        } else {
 | 
						|
            $this->table(['ID', 'UUID', 'Name', 'Host'], $nodes->toArray());
 | 
						|
        }
 | 
						|
 | 
						|
        $this->output->newLine();
 | 
						|
 | 
						|
        return 0;
 | 
						|
    }
 | 
						|
}
 |