mirror of
https://github.com/jbcr/core.git
synced 2026-03-30 12:52:16 +02:00
19 lines
587 B
PHP
19 lines
587 B
PHP
<?php
|
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
function run(string $command, SymfonyStyle $symfonyStyle, bool $withOutput = false): void {
|
|
exec($command, $output, $return);
|
|
if ($return) {
|
|
// Some error occurred.
|
|
$message = sprintf("Command '%s' failed. %s", $command, implode("\n", $output));
|
|
$symfonyStyle->error($message);
|
|
} else {
|
|
if ($withOutput) {
|
|
$symfonyStyle->text($output);
|
|
}
|
|
$message = sprintf("Command '%s' executed successfully.", $command);
|
|
$symfonyStyle->success($message);
|
|
}
|
|
}
|