From fb236c1bb3d825bd767c295c8f6a1c0d1e65838f Mon Sep 17 00:00:00 2001 From: Jakub Turek Date: Sun, 8 Mar 2015 12:36:54 +0100 Subject: [PATCH] Enable running help command in Console --- Mage/Console.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Mage/Console.php b/Mage/Console.php index d9fcbb2..ef29492 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -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 Magallanes', 0, 2); + } else { self::output('Starting Magallanes', 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('' . $configError . '', 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); } + }