2.x - console (wip)

This commit is contained in:
Saeed Vaziry
2024-10-02 23:46:53 +02:00
parent 906ddc38de
commit 63e7cfd8f7
9 changed files with 181 additions and 9 deletions

View File

@ -91,7 +91,7 @@ public function connect(bool $sftp = false): void
/**
* @throws SSHError
*/
public function exec(string $command, string $log = '', ?int $siteId = null, ?bool $stream = false): string
public function exec(string $command, string $log = '', ?int $siteId = null, ?bool $stream = false, ?callable $streamCallback = null): string
{
if (! $this->log && $log) {
$this->log = ServerLog::make($this->server, $log);
@ -116,11 +116,10 @@ public function exec(string $command, string $log = '', ?int $siteId = null, ?bo
$this->connection->setTimeout(0);
if ($stream) {
$this->connection->exec($command, function ($output) {
$this->connection->exec($command, function ($output) use ($streamCallback) {
$this->log?->write($output);
echo $output;
ob_flush();
flush();
return $streamCallback($output);
});
return '';