From: Vincent Vanwaelscappel Date: Wed, 25 Jan 2023 12:44:58 +0000 (+0100) Subject: wip #5661 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b4f0533e198b06cda30ac32df0a82040367a086d;p=cubist_util.git wip #5661 @0.5 --- diff --git a/src/CommandLine.php b/src/CommandLine.php index 6ae43cb..3fa383a 100644 --- a/src/CommandLine.php +++ b/src/CommandLine.php @@ -3,6 +3,7 @@ namespace Cubist\Util; use Cubist\Net\SSH2; +use Illuminate\Support\Facades\Log; class CommandLine { @@ -258,9 +259,7 @@ class CommandLine public function debug() { - $e = explode('/', $this->program); - $p = array_pop($e); - file_put_contents('/tmp/' . $p . '.' . microtime(true) . '.txt', $this->commande . "\n\n" . file_get_contents($this->output)); + Log::debug($this->commande . "\n\n" . file_get_contents($this->output)); } public function dd() diff --git a/src/CommandLine/Rsync.php b/src/CommandLine/Rsync.php index df4caef..c7e190f 100644 --- a/src/CommandLine/Rsync.php +++ b/src/CommandLine/Rsync.php @@ -16,6 +16,10 @@ class Rsync extends CommandLine protected $_deleteExcluded = false; protected $_prog = '/usr/bin/rsync'; protected $_sshKey = null; + /** + * @var bool + */ + protected $_dryRun = false; public function getSshKey() { @@ -140,6 +144,9 @@ class Rsync extends CommandLine if ($this->getDeleteExcluded()) { $this->setArg('delete-excluded'); } + if ($this->isDryRun()) { + $this->setArg('dry-run'); + } $this->setArg('t'); $this->setArg('r'); $this->setArg('v'); @@ -170,4 +177,20 @@ class Rsync extends CommandLine $this->setMirror($mirror); } + /** + * @param bool $dryRun + */ + public function setDryRun(bool $dryRun): void + { + $this->_dryRun = $dryRun; + } + + /** + * @return bool + */ + public function isDryRun(): bool + { + return $this->_dryRun; + } + }