diff --git a/app/Commands/ServerListCommand.php b/app/Commands/ServerListCommand.php new file mode 100644 index 0000000..6acbffd --- /dev/null +++ b/app/Commands/ServerListCommand.php @@ -0,0 +1,41 @@ +lookupRemoteServers())->map(function ($server) { + return [ + 'key' => $server['key'], + 'region' => $server['region'], + 'plan' => Str::ucfirst($server['plan']), + ]; + }); + + $this->info('You can connect to a specific server with the --server=key option or set this server as default with the default-server command.'); + $this->info(''); + + $this->table(['Key', 'Region', 'Type'], $servers); + } + + protected function lookupRemoteServers() + { + try { + return Http::get(config('expose.server_endpoint', static::DEFAULT_SERVER_ENDPOINT))->json(); + } catch (\Throwable $e) { + return []; + } + } +}