Enable running help command in Console

This commit is contained in:
Jakub Turek 2015-03-08 12:36:54 +01:00
parent 342a468214
commit fb236c1bb3

View file

@ -13,6 +13,7 @@ namespace Mage;
use Mage\Command\Factory;
use Mage\Command\RequiresEnvironment;
use Mage\Console\Colors;
use Exception;
use RecursiveDirectoryIterator;
use SplFileInfo;
@ -94,6 +95,7 @@ class Console
try {
// Load configuration
$config->load($arguments);
} catch (Exception $exception) {
$configError = $exception->getMessage();
}
@ -117,6 +119,7 @@ class Console
if ($showGreetings) {
if (!self::$logEnabled) {
self::output('Starting <blue>Magallanes</blue>', 0, 2);
} else {
self::output('Starting <blue>Magallanes</blue>', 0, 1);
self::log("Logging enabled");
@ -127,15 +130,20 @@ class Console
// Run Command - Check if there is a Configuration Error
if ($configError !== false) {
self::output('<red>' . $configError . '</red>', 1, 2);
} else {
// Run Command and check for Command Requirements
try {
$command = Factory::get($commandName, $config);
if ($command instanceof RequiresEnvironment) {
if ($config->getEnvironment() === false) {
throw new Exception('You must specify an environment for this command.');
}
if ($config->getParameter('help')) {
self::output($command->getInfoMessage(), 2);
return 0;
}
if ($command instanceof RequiresEnvironment && $config->getEnvironment() === false) {
throw new Exception('You must specify an environment for this command.');
}
// Run the Command
@ -306,4 +314,5 @@ class Console
|| self::$config->general('verbose_logging')
|| self::$config->environmentConfig('verbose_logging', false);
}
}