From af5bad2ebec6c5a1262d3a75bc831e08bfd76fd1 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 11 Mar 2020 19:33:58 +0100 Subject: [PATCH] wip #3490 @1 --- src/app/Console/Commands/CubistCommand.php | 27 +++++++++++++------ .../Magic/Models/CubistMagicAuthenticable.php | 21 +++++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 src/app/Magic/Models/CubistMagicAuthenticable.php diff --git a/src/app/Console/Commands/CubistCommand.php b/src/app/Console/Commands/CubistCommand.php index 2e39184..f95e2e4 100644 --- a/src/app/Console/Commands/CubistCommand.php +++ b/src/app/Console/Commands/CubistCommand.php @@ -10,18 +10,27 @@ use Symfony\Component\Process\Process; class CubistCommand extends Command { + public function executeProcessQuiet($command) + { + return $this->executeProcess($command, '', '', false); + } + + /** * Run a SSH command. * * @param string|array $command The SSH command that needs to be run * @param bool $beforeNotice Information for the user before the command is run * @param bool $afterNotice Information for the user after the command is run + * @param bool $output * * @return mixed Command-line output */ - public function executeProcess($command, $beforeNotice = false, $afterNotice = false) + public function executeProcess($command, $beforeNotice = false, $afterNotice = false, $output = true) { - $this->echo('info', $beforeNotice ? ' ' . $beforeNotice : $command); + if ($output) { + $this->echo('info', $beforeNotice ? ' ' . $beforeNotice : $command); + } if (is_string($command)) { $process = Process::fromShellCommandline($command, null, null, null, 180); @@ -30,11 +39,13 @@ class CubistCommand extends Command } - $process->run(function ($type, $buffer) { - if (Process::ERR === $type) { - $this->echo('comment', $buffer); - } else { - $this->echo('line', $buffer); + $process->run(function ($type, $buffer) use ($output) { + if ($output) { + if (Process::ERR === $type) { + $this->echo('comment', $buffer); + } else { + $this->echo('line', $buffer); + } } }); @@ -43,7 +54,7 @@ class CubistCommand extends Command throw new ProcessFailedException($process); } - if ($afterNotice) { + if ($afterNotice && $output) { $this->echo('info', $afterNotice); } } diff --git a/src/app/Magic/Models/CubistMagicAuthenticable.php b/src/app/Magic/Models/CubistMagicAuthenticable.php new file mode 100644 index 0000000..4d1dc92 --- /dev/null +++ b/src/app/Magic/Models/CubistMagicAuthenticable.php @@ -0,0 +1,21 @@ +