diff --git a/cake/console/cake.php b/cake/console/cake.php index 04d53987f..498fc0916 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -273,6 +273,7 @@ class ShellDispatcher { if($command == 'help') { if(method_exists($shell, 'help')) { + $shell->startup(); $shell->help(); exit(); } else { @@ -285,6 +286,7 @@ class ShellDispatcher { $this->shiftArgs(); $shell->{$task}->initialize(); $shell->{$task}->loadTasks(); + $shell->{$task}->startup(); $shell->{$task}->execute(); return; } @@ -311,10 +313,14 @@ class ShellDispatcher { } if($missingCommand && method_exists($shell, 'main')) { + $this->args = am(array($command), $this->args); + $shell->startup(); $shell->main(); } else if($missingCommand && method_exists($shell, 'help')) { + $shell->startup(); $shell->help(); } else if(!$privateMethod && method_exists($shell, $command)) { + $shell->startup(); $shell->{$command}(); } else { $this->stderr("Unknown {$this->shellName} command '$command'.\nFor usage, try 'cake {$this->shell} help'.\n\n"); diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php index 155734547..c0a2f31fd 100644 --- a/cake/console/libs/acl.php +++ b/cake/console/libs/acl.php @@ -57,10 +57,10 @@ class AclShell extends Shell { */ var $tasks = array('DbConfig'); /** - * override intialize of the Shell + * override startup of the Shell * */ - function initialize () { + function startup() { $this->dataSource = 'default'; if (isset($this->params['datasource'])) { @@ -81,8 +81,10 @@ class AclShell extends Shell { } if($this->command && !in_array($this->command, array('help'))) { - if(!file_exists(CONFIGS.'database.php')) { - $this->DbConfig->execute(); + if(!config('database')) { + $this->out("Your database configuration was not found. Take a moment to create one.\n"); + $this->args = null; + return $this->DbConfig->execute(); } require_once (CONFIGS.'database.php'); diff --git a/cake/console/libs/api.php b/cake/console/libs/api.php index fcfecaa05..ae1bbc2b4 100644 --- a/cake/console/libs/api.php +++ b/cake/console/libs/api.php @@ -65,11 +65,10 @@ class ApiShell extends Shell { if (empty($this->args)) { return $this->help(); } - if (count($this->args) == 1 && in_array($this->args[0], array_keys($this->paths))) { $this->args[1] = $this->args[0]; - } - + } + if (count($this->args) > 1) { $path = $this->args[0]; $class = $this->args[1]; @@ -103,7 +102,7 @@ class ApiShell extends Shell { Inflector::underscore($class), substr(Inflector::underscore($class), 0, strpos(Inflector::underscore($class), '_')) ); - + foreach($candidates as $candidate) { $File =& new File($path . $candidate . '.php'); diff --git a/cake/console/libs/bake.php b/cake/console/libs/bake.php index 120f35325..6cfad567c 100644 --- a/cake/console/libs/bake.php +++ b/cake/console/libs/bake.php @@ -38,8 +38,6 @@ class BakeShell extends Shell { var $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View'); - function initialize() {} - function main() { if(!is_dir(CONFIGS)) { @@ -48,7 +46,8 @@ class BakeShell extends Shell { if(!config('database')) { $this->out("Your database configuration was not found. Take a moment to create one.\n"); - $this->DbConfig->execute(); + $this->args = null; + return $this->DbConfig->execute(); } $this->out('Interactive Bake Shell'); $this->hr(); diff --git a/cake/console/libs/shell.php b/cake/console/libs/shell.php index 7f5909b6f..436eab214 100644 --- a/cake/console/libs/shell.php +++ b/cake/console/libs/shell.php @@ -130,17 +130,27 @@ class Shell extends Object { } if(!PHP5 && isset($this->args[0]) && low($this->command) == low(Inflector::variable($this->args[0]))) { $dispatch->shiftArgs(); - } + } $this->Dispatch =& $dispatch; } /** * Initializes the Shell - * can be overriden in subclasses + * acts as constructor for subclasses + * allows configuration of tasks prior to shell execution * * @return void */ function initialize() { $this->_loadModels(); + } +/** + * Starts up the the Shell + * allows for checking and configuring prior to command or main execution + * can be overriden in subclasses + * + * @return void + */ + function startup() { $this->_welcome(); } /** diff --git a/cake/console/libs/tasks/project.php b/cake/console/libs/tasks/project.php index cddbe3ce3..1d0a6d56e 100644 --- a/cake/console/libs/tasks/project.php +++ b/cake/console/libs/tasks/project.php @@ -29,6 +29,12 @@ if(!class_exists('File')) { uses('file'); } +/** + * Task class for creating new project apps and plugins + * + * @package cake + * @subpackage cake.cake.console.libs.tasks + */ class ProjectTask extends Shell { /**