From b127b4d252367d8135fe9742f20606cca96f191a Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Wed, 4 Sep 2024 13:04:08 +0200 Subject: [PATCH] Add OpenCommand --- app/Commands/OpenCommand.php | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 app/Commands/OpenCommand.php diff --git a/app/Commands/OpenCommand.php b/app/Commands/OpenCommand.php new file mode 100644 index 0000000..814b5db --- /dev/null +++ b/app/Commands/OpenCommand.php @@ -0,0 +1,55 @@ +askForSite('Which site would you like to open'); + $serverId = $this->currentServer()->id; + + $url = "https://forge.laravel.com/servers/$serverId/sites/$siteId"; + + $os = strtolower(php_uname(PHP_OS)); + + if (strpos($os, 'darwin') !== false) { + $open = 'open'; + } elseif (strpos($os, 'linux') !== false) { + $open = 'xdg-open'; + } else { + $this->step("Can't open your browser, you'll have to manually navigate to {$url}"); + return; + } + + $this->step("Opening site in your browser..."); + + $command = [$open, $url]; + + $process = new Process($command); + $process->run(); + } +}