]> _ Git - cubist_util.git/commitdiff
wip #5661 @0.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Jan 2023 12:44:58 +0000 (13:44 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 25 Jan 2023 12:44:58 +0000 (13:44 +0100)
src/CommandLine.php
src/CommandLine/Rsync.php

index 6ae43cb59106ac811035d23009780c2309865f09..3fa383aad3acbfc756bc2c2ef23663b46c982a97 100644 (file)
@@ -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()
index df4caeff02155c1fc7ea0858bc912a3a28cd285f..c7e190f76103969e78e4a6ff1ae3675d10957768 100644 (file)
@@ -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;
+    }
+
 }