refactoring shell paths, also closes #5451, shell to return exit values

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7762 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-10-18 19:54:56 +00:00
parent 66cfeee8c7
commit f861d685d5
2 changed files with 28 additions and 28 deletions

View file

@ -129,8 +129,7 @@ class ShellDispatcher {
$this->__initConstants();
$this->parseParams($args);
$this->__initEnvironment();
$this->dispatch();
die("\n");
exit($this->dispatch());
}
/**
* Defines core configuration.
@ -191,11 +190,29 @@ class ShellDispatcher {
}
$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;
}
}
}
$this->shellPaths[] = CONSOLE_LIBS;
$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 = array_values(array_unique(array_merge($paths, Configure::read('shellPaths'))));
}
/**
* Initializes the environment and loads the Cake core.
@ -262,22 +279,6 @@ class ShellDispatcher {
$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";
@ -323,8 +324,7 @@ class ShellDispatcher {
$this->help();
}
}
$shell->{$task}->execute();
return;
return $shell->{$task}->execute();
}
}
@ -353,11 +353,11 @@ class ShellDispatcher {
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");
}

View file

@ -503,7 +503,7 @@ class Configure extends Object {
$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;
}
}
@ -586,7 +586,7 @@ class Configure extends Object {
'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) {