Skip to content

Commit

Permalink
refactoring shell paths, also closes #5451, shell to return exit values
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7762 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
gwoo committed Oct 18, 2008
1 parent 66cfeee commit f861d68
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
52 changes: 26 additions & 26 deletions cake/console/cake.php
Expand Up @@ -129,8 +129,7 @@ function __construct($args = array()) {
$this->__initConstants();
$this->parseParams($args);
$this->__initEnvironment();
$this->dispatch();
die("\n");
exit($this->dispatch());
}
/**
* Defines core configuration.
Expand Down Expand Up @@ -191,11 +190,29 @@ function __initEnvironment() {
}

$this->shiftArgs();
$vendorPaths = Configure::read('vendorPaths');
foreach ($vendorPaths as $path) {
$this->shellPaths[] = $path . 'shells' . DS;

$paths = array();

$pluginPaths = Configure::read('pluginPaths');
foreach ($pluginPaths as $pluginPath) {
$plugins = Configure::listObjects('plugin', $pluginPath);
foreach ((array)$plugins as $plugin) {
$path = $pluginPath . strtolower($plugin) . DS . 'vendors' . DS . 'shells' . DS;
if (file_exists($path)) {
$paths[] = $path;
}
}
}

$vendorPaths = array_values(Configure::read('vendorPaths'));
foreach ($vendorPaths as $vendorPath) {
$path = rtrim($vendorPath, DS) . DS . 'shells' . DS;
if (file_exists($path)) {
$paths[] = $path;
}
}
$this->shellPaths[] = CONSOLE_LIBS;

$this->shellPaths = array_values(array_unique(array_merge($paths, Configure::read('shellPaths'))));
}
/**
* Initializes the environment and loads the Cake core.
Expand Down Expand Up @@ -262,22 +279,6 @@ function dispatch() {
$this->help();
} else {
$loaded = false;
$paths = array();

if ($plugin !== null) {
$pluginPaths = Configure::read('pluginPaths');
$count = count($pluginPaths);
for ($i = 0; $i < $count; $i++) {
$paths[] = $pluginPaths[$i] . $plugin . DS . 'vendors' . DS . 'shells' . DS;
}
}

$vendorPaths = array_values(Configure::read('vendorPaths'));
$count = count($vendorPaths);

for ($i = 0; $i < $count; $i++) {
$paths[] = rtrim($vendorPaths[$i], DS) . DS . 'shells' . DS;
}

foreach ($this->shellPaths as $path) {
$this->shellPath = $path . $this->shell . ".php";
Expand Down Expand Up @@ -323,8 +324,7 @@ function dispatch() {
$this->help();
}
}
$shell->{$task}->execute();
return;
return $shell->{$task}->execute();
}
}

Expand Down Expand Up @@ -353,11 +353,11 @@ function dispatch() {

if ($missingCommand && method_exists($shell, 'main')) {
$shell->startup();
$shell->main();
return $shell->main();
} elseif (!$privateMethod && method_exists($shell, $command)) {
$this->shiftArgs();
$shell->startup();
$shell->{$command}();
return $shell->{$command}();
} else {
$this->stderr("Unknown {$this->shellName} command '$command'.\nFor usage, try 'cake {$this->shell} help'.\n\n");
}
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/configure.php
Expand Up @@ -503,7 +503,7 @@ function corePaths($type = null) {
$paths['cake'][] = $cake;
$paths['class'][] = $cake;
$paths['vendor'][] = $path . DS . 'vendors' . DS;
$paths['shell'][] = $path . DS . 'console' . DS . 'libs' . DS ;
$paths['shell'][] = $cake . 'console' . DS . 'libs' . DS;
break;
}
}
Expand Down Expand Up @@ -586,7 +586,7 @@ function buildPaths($paths) {
'plugin' => array(APP . 'plugins' . DS),
'vendor' => array(APP . 'vendors' . DS, VENDORS),
'locale' => array(APP . 'locale' . DS),
'shell' => array(APP . 'vendors' . DS . 'shells' . DS)
'shell' => array()
);

foreach ($basePaths as $type => $default) {
Expand Down

0 comments on commit f861d68

Please sign in to comment.