add Shell with ERROR and SUCCESS code

This commit is contained in:
Tomas Votruba 2018-09-19 01:06:58 +02:00
parent db0fef557d
commit 336ee32f92
4 changed files with 26 additions and 5 deletions

View File

@ -5,6 +5,7 @@ namespace Rector\Console\Command;
use Nette\Loaders\RobotLoader;
use Nette\Utils\Strings;
use Rector\Console\ConsoleStyle;
use Rector\Console\Shell;
use Rector\ConsoleDiffer\MarkdownDifferAndFormatter;
use Rector\Contract\Rector\RectorInterface;
use Rector\Exception\ShouldNotHappenException;
@ -65,8 +66,7 @@ final class GenerateRectorOverviewCommand extends Command
$rectorsByGroup = $this->groupRectors($this->getGeneralRectors());
$this->printRectorsByGroup($rectorsByGroup);
// success
return 0;
return Shell::CODE_SUCCESS;
}
/**

View File

@ -4,6 +4,7 @@ namespace Rector\Console\Command;
use Nette\Utils\Strings;
use Rector\Console\ConsoleStyle;
use Rector\Console\Shell;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@ -43,7 +44,7 @@ final class LevelsCommand extends Command
$this->consoleStyle->title(sprintf('%d available levels:', count($levels)));
$this->consoleStyle->listing($levels);
return 0;
return Shell::CODE_SUCCESS;
}
/**

View File

@ -10,6 +10,7 @@ use Rector\Autoloading\AdditionalAutoloader;
use Rector\Configuration\Option;
use Rector\Console\ConsoleStyle;
use Rector\Console\Output\ProcessCommandReporter;
use Rector\Console\Shell;
use Rector\ConsoleDiffer\DifferAndFormatter;
use Rector\FileSystem\FilesFinder;
use Rector\Guard\RectorGuard;
@ -165,7 +166,7 @@ final class ProcessCommand extends Command
if ($this->errors) {
$this->processCommandReporter->reportErrors($this->errors);
return 1;
return Shell::CODE_ERROR;
}
if ($input->getOption(Option::OPTION_WITH_STYLE)) {
@ -179,7 +180,7 @@ final class ProcessCommand extends Command
$this->consoleStyle->success('Rector is done!');
return 0;
return Shell::CODE_SUCCESS;
}
/**

19
src/Console/Shell.php Normal file
View File

@ -0,0 +1,19 @@
<?php declare(strict_types=1);
namespace Rector\Console;
/**
* Mimics https://github.com/cakephp/cakephp/blob/ae7ec50e12adbb30d9e7d1187b385bc32b7d31dc/src/Console/Shell.php#L39
*/
final class Shell
{
/**
* @var int
*/
public const CODE_ERROR = 1;
/**
* @var int
*/
public const CODE_SUCCESS = 0;
}