Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / robo / src / Task / Docker / Exec.php
diff --git a/vendor/consolidation/robo/src/Task/Docker/Exec.php b/vendor/consolidation/robo/src/Task/Docker/Exec.php
new file mode 100644 (file)
index 0000000..fa67c8d
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+namespace Robo\Task\Docker;
+
+use Robo\Common\CommandReceiver;
+
+/**
+ * Executes command inside running Docker container
+ *
+ * ```php
+ * <?php
+ * $test = $this->taskDockerRun('test_env')
+ *      ->detached()
+ *      ->run();
+ *
+ * $this->taskDockerExec($test)
+ *      ->interactive()
+ *      ->exec('./runtests')
+ *      ->run();
+ *
+ * // alternatively use commands from other tasks
+ *
+ * $this->taskDockerExec($test)
+ *      ->interactive()
+ *      ->exec($this->taskCodecept()->suite('acceptance'))
+ *      ->run();
+ * ?>
+ * ```
+ *
+ */
+class Exec extends Base
+{
+    use CommandReceiver;
+
+    /**
+     * @var string
+     */
+    protected $command = "docker exec";
+
+    /**
+     * @var string
+     */
+    protected $cid;
+
+    /**
+     * @var string
+     */
+    protected $run = '';
+
+    /**
+     * @param string|\Robo\Result $cidOrResult
+     */
+    public function __construct($cidOrResult)
+    {
+        $this->cid = $cidOrResult instanceof Result ? $cidOrResult->getCid() : $cidOrResult;
+    }
+
+    /**
+     * @return $this
+     */
+    public function detached()
+    {
+        $this->option('-d');
+        return $this;
+    }
+
+    /**
+     * {@inheritdoc)}
+     */
+    public function interactive($interactive = true)
+    {
+        if ($interactive) {
+            $this->option('-i');
+        }
+        return parent::interactive($interactive);
+    }
+
+    /**
+     * @param string|\Robo\Contract\CommandInterface $command
+     *
+     * @return $this
+     */
+    public function exec($command)
+    {
+        $this->run = $this->receiveCommand($command);
+        return $this;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getCommand()
+    {
+        return $this->command . ' ' . $this->arguments . ' ' . $this->cid.' '.$this->run;
+    }
+}