Skip to content

Commit

Permalink
Merge pull request magento#1031 from magento-ogre/develop
Browse files Browse the repository at this point in the history
[Ogre] Bug fix, MAGETWO-31889
  • Loading branch information
Olga Kopylova committed Dec 16, 2014
2 parents 76d6838 + c3714c2 commit b9d7cf1
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 40 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"zendframework/zend-serializer": "2.3.1",
"zendframework/zend-log": "2.3.1",
"zendframework/zend-http": "2.3.1",
"magento/zendframework1": "1.12.9",
"magento/zendframework1": "1.12.9-patch1",
"composer/composer": "1.0.0-alpha8"
},
"require-dev": {
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 1 addition & 25 deletions setup/module/Magento/Setup/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,17 @@

namespace Magento\Setup;

use Magento\Setup\Controller\ConsoleController;
use Magento\Setup\Mvc\Bootstrap\InitParamListener;
use Magento\Setup\Mvc\View\Http\InjectTemplateListener;
use Zend\Console\Adapter\AdapterInterface;
use Zend\EventManager\EventInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ConsoleBannerProviderInterface;
use Zend\ModuleManager\Feature\ConsoleUsageProviderInterface;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;

class Module implements
BootstrapListenerInterface,
ConfigProviderInterface,
ConsoleBannerProviderInterface,
ConsoleUsageProviderInterface
ConfigProviderInterface
{
/**
* {@inheritdoc}
Expand Down Expand Up @@ -74,22 +68,4 @@ public function getConfig()
$result = InitParamListener::attachToConsoleRoutes($result);
return $result;
}

/**
* {@inheritdoc}
*/
public function getConsoleBanner(AdapterInterface $console)
{
return "==-------------------==\n"
. " Magento Setup CLI \n"
. "==-------------------==\n";
}

/**
* {@inheritdoc}
*/
public function getConsoleUsage(AdapterInterface $console)
{
return array_merge(ConsoleController::getConsoleUsage(), InitParamListener::getConsoleUsage());
}
}
39 changes: 38 additions & 1 deletion setup/module/Magento/Setup/src/Controller/ConsoleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
use Magento\Setup\Model\InstallerFactory;
use Magento\Setup\Model\Lists;
use Magento\Setup\Model\UserConfigurationDataMapper as UserConfig;
use Magento\Setup\Mvc\Bootstrap\InitParamListener;
use Zend\Console\Request as ConsoleRequest;
use Zend\EventManager\EventManagerInterface;
use Zend\Mvc\Controller\AbstractActionController;


/**
* Controller that handles all setup commands via command line interface.
*
Expand Down Expand Up @@ -242,7 +244,7 @@ private static function getCliConfig()
'usage_desc' => 'Set maintenance mode, optionally for specified addresses',
],
self::CMD_HELP => [
'route' => self::CMD_HELP . ' (' . implode('|', self::$helpOptions) . '):type',
'route' => self::CMD_HELP . ' [' . implode('|', self::$helpOptions) . ']:type',
'usage' => '<' . implode('|', self::$helpOptions) . '>',
'usage_short' => self::CMD_HELP . ' <topic>',
'usage_desc' => 'Help about particular command or topic:',
Expand Down Expand Up @@ -433,6 +435,12 @@ public function maintenanceAction()
public function helpAction()
{
$type = $this->getRequest()->getParam('type');
if ($type === false) {
$usageInfo = $this->formatConsoleFullUsageInfo(
array_merge(self::getConsoleUsage(), InitParamListener::getConsoleUsage())
);
return $usageInfo;
}
$usages = self::getCommandUsage();
switch($type) {
case UserConfig::KEY_LANGUAGE:
Expand All @@ -453,6 +461,35 @@ public function helpAction()
}
}

/**
* Formats full usage info for console when user inputs 'help' command with no type
*
* @param array $usageInfo
* @return string
*/
private function formatConsoleFullUsageInfo($usageInfo)
{
$result = "\n==-------------------==\n"
. " Magento Setup CLI \n"
. "==-------------------==\n";
$mask = "%-50s %-30s\n";
$script = 'index.php';
foreach ($usageInfo as $key => $value) {
if ($key === 0) {
$result .= sprintf($mask, "\n$value", '');
} elseif (is_numeric($key)) {
if (is_array($value)) {
$result .= sprintf($mask, " " . $value[0], $value[1]);
} else {
$result .= sprintf($mask, '', $value);
}
} else {
$result .= sprintf($mask, " $script " . $key, $value);
}
}
return $result;
}

/**
* Formats output of "usage" into more readable format by grouping required/optional parameters and wordwrapping
*
Expand Down
15 changes: 8 additions & 7 deletions setup/module/Magento/Setup/src/Mvc/Console/VerboseValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ class VerboseValidator
public function validate(array $data, array $config)
{
$validationMessages = '';
$userAction = null;
if (!empty($data)) {
$userAction = $data[0];
array_shift($data);
} else {
// user did not provide any action or parameters, treat as default action
return '';
}

if (isset($config[$userAction])) {
if (isset($userAction) && isset($config[$userAction])) {
// parse the expected parameters of the action
$matcher = new RouteMatcher($config[$userAction]['options']['route']);
$parts = $matcher->getParts();
Expand Down Expand Up @@ -87,8 +84,12 @@ public function validate(array $data, array $config)
$validationMessages .= 'Usage:' . PHP_EOL . "{$userAction} ";
$validationMessages .= $usages[$userAction] . PHP_EOL . PHP_EOL;

} else if (!is_null($userAction)) {
$validationMessages .= PHP_EOL . "Unknown action name '{$userAction}'." . PHP_EOL . PHP_EOL;
} else {
if (!is_null($userAction)) {
$validationMessages .= PHP_EOL . "Unknown action name '{$userAction}'." . PHP_EOL . PHP_EOL;
} else {
$validationMessages .= PHP_EOL . "No action is given in the command." . PHP_EOL . PHP_EOL;
}
$validationMessages .= 'Available options: ' . PHP_EOL;
foreach (array_keys($config) as $action) {
$validationMessages .= $action . PHP_EOL;
Expand Down

0 comments on commit b9d7cf1

Please sign in to comment.