Parsing every parameter until there is no more. Good to have alias but with the ability to override the arguments.

This commit is contained in:
Renan Gonçalves 2011-10-21 12:20:31 +02:00
parent 9f80004920
commit d9e8b3b6a2
2 changed files with 20 additions and 2 deletions

View file

@ -288,8 +288,7 @@ class ShellDispatcher {
$parsed = array();
$keys = array('-working', '--working', '-app', '--app', '-root', '--root');
foreach ($keys as $key) {
$index = array_search($key, $args);
if ($index !== false) {
while (($index = array_search($key, $args)) !== false) {
$keyname = str_replace('-', '', $key);
$valueIndex = $index + 1;
$parsed[$keyname] = $args[$valueIndex];

View file

@ -365,6 +365,25 @@ class ShellDispatcherTest extends CakeTestCase {
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
$params = array(
'/cake/1.2.x.x/cake/console/cake.php',
'bake',
'-app',
'new',
'-app',
'old',
'-working',
'/var/www/htdocs'
);
$expected = array(
'app' => 'old',
'webroot' => 'webroot',
'working' => str_replace('/', DS, '/var/www/htdocs/old'),
'root' => str_replace('/', DS,'/var/www/htdocs')
);
$Dispatcher->parseParams($params);
$this->assertEqual($expected, $Dispatcher->params);
if (DS === '\\') {
$params = array(
'cake.php',