mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
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:
parent
9f80004920
commit
d9e8b3b6a2
2 changed files with 20 additions and 2 deletions
|
@ -288,8 +288,7 @@ class ShellDispatcher {
|
||||||
$parsed = array();
|
$parsed = array();
|
||||||
$keys = array('-working', '--working', '-app', '--app', '-root', '--root');
|
$keys = array('-working', '--working', '-app', '--app', '-root', '--root');
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
$index = array_search($key, $args);
|
while (($index = array_search($key, $args)) !== false) {
|
||||||
if ($index !== false) {
|
|
||||||
$keyname = str_replace('-', '', $key);
|
$keyname = str_replace('-', '', $key);
|
||||||
$valueIndex = $index + 1;
|
$valueIndex = $index + 1;
|
||||||
$parsed[$keyname] = $args[$valueIndex];
|
$parsed[$keyname] = $args[$valueIndex];
|
||||||
|
|
|
@ -365,6 +365,25 @@ class ShellDispatcherTest extends CakeTestCase {
|
||||||
$Dispatcher->parseParams($params);
|
$Dispatcher->parseParams($params);
|
||||||
$this->assertEqual($expected, $Dispatcher->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 === '\\') {
|
if (DS === '\\') {
|
||||||
$params = array(
|
$params = array(
|
||||||
'cake.php',
|
'cake.php',
|
||||||
|
|
Loading…
Add table
Reference in a new issue