for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Schnittstabil\Dartisan\Commands;
use Garden\Cli\Cli;
use Garden\Cli\Args;
use Illuminate\Database\Migrations\Migrator;
abstract class Command
{
protected $outputFormatter;
public function __construct(callable $outputFormatter)
$this->outputFormatter = $outputFormatter;
}
abstract protected function run();
public function __invoke()
try {
return $this->run();
} catch(\Exception $e) {
$this->echoError($e);
return 2;
protected function echo($msg, bool $eol = true)
$outputFormatter = $this->outputFormatter;
$output = $outputFormatter($msg);
if ($eol) {
$output .= PHP_EOL;
echo $output;
protected function echoError($msg, bool $eol = true)
$this->echo('<error>'.$msg.'</error>', $eol);
protected function echoInfo($msg, bool $eol = true)
$this->echo('<info>'.$msg.'</info>', $eol);
protected function echoNotes($notes)
foreach ($notes as $note) {
$this->echo($note);