From 1875d74e4aea66545328bbce00295a84ae585330 Mon Sep 17 00:00:00 2001 From: gwoo Date: Sun, 13 May 2007 20:49:37 +0000 Subject: [PATCH] updating shell task handling, removing bake2 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5076 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/console/cake.php | 11 ++-- cake/console/error.php | 4 +- cake/console/libs/bake2.php | 104 ------------------------------------ cake/console/libs/shell.php | 12 +++-- 4 files changed, 16 insertions(+), 115 deletions(-) delete mode 100644 cake/console/libs/bake2.php diff --git a/cake/console/cake.php b/cake/console/cake.php index 38144df90..d817e790c 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -272,16 +272,15 @@ class ShellDispatcher { if(isset($this->args[0])) { $command = $this->args[0]; } - + $task = Inflector::camelize($command); if(in_array($task, $shell->taskNames)) { - $shell->initialize(); $task = Inflector::camelize($command); $shell->{$task}->initialize(); $shell->{$task}->execute(); return; } - + $classMethods = get_class_methods($shell); $privateMethod = $missingCommand = false; @@ -296,7 +295,7 @@ class ShellDispatcher { if (in_array(strtolower($command), $protectedCommands)) { $missingCommand = true; } - + if($command == 'help') { if(method_exists($shell, 'help')) { $shell->command = $command; @@ -408,12 +407,12 @@ class ShellDispatcher { $app = $this->params['app']; } } - + if(empty($this->params['app']) && in_array($app, array('cake', 'console', 'app'))){ $app = 'app'; $this->params['working'] = dirname(dirname(__FILE__)); } - + if($app !== basename($this->params['working']) && $this->params['working'] !== dirname(dirname(__FILE__))) { $this->params['root'] = $this->params['working']; } diff --git a/cake/console/error.php b/cake/console/error.php index a8e2621e3..6bae879d7 100644 --- a/cake/console/error.php +++ b/cake/console/error.php @@ -19,8 +19,8 @@ * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project * @package cake - * @subpackage cake.cake.libs - * @since CakePHP(tm) v 0.10.5.1732 + * @subpackage cake.cake.console + * @since CakePHP(tm) v 1.2.0.5074 * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ diff --git a/cake/console/libs/bake2.php b/cake/console/libs/bake2.php deleted file mode 100644 index 4a77db592..000000000 --- a/cake/console/libs/bake2.php +++ /dev/null @@ -1,104 +0,0 @@ - - * Copyright 2005-2007, Cake Software Foundation, Inc. - * 1785 E. Sahara Avenue, Suite 490-204 - * Las Vegas, Nevada 89104 - * - * Licensed under The MIT License - * Redistributions of files must retain the above copyright notice. - * - * @filesource - * @copyright Copyright 2005-2007, Cake Software Foundation, Inc. - * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project - * @package cake - * @subpackage cake.cake.scripts.bake - * @since CakePHP(tm) v 1.2 - * @version $Revision$ - * @modifiedby $LastChangedBy$ - * @lastmodified $Date$ - * @license http://www.opensource.org/licenses/mit-license.php The MIT License - */ -class Bake2Shell extends Shell { - - var $task = null; - - function initialize() { - pr($this->args); - if(isset($this->args[0])) { - $this->task = $this->args[0]; - } - } - - function main() { - if($this->task == null) { - $this->err('No Task specified'); - exit(); - } - - $task = $this->_loadTask($this->task); - if ($task !== null) { - $task->execute($this->args); - } else { - $this->err("Task not found: " . $this->task . "\n"); - } - } - - function _loadTask($taskName = null) { - - if(!$taskName) { - $taskName = $this->task; - } - - if(!$taskName) { - return null; - } - - $loaded = false; - foreach($this->Dispatch->shellPaths as $path) { - $this->taskPath = $path . 'tasks' . DS . $taskName.'.php'; - if (file_exists($this->taskPath)) { - $loaded = true; - break; - } - } - - if ($loaded) { - require CONSOLE_LIBS . 'tasks' . DS . 'bake.php'; - require $this->taskPath; - - $this->taskClass = $taskName.'Task'; - if(class_exists($this->taskClass)) { - return new $this->taskClass($this); - } - } - return null; - } - - function _readConfigFile($fileName) { - $fileLineArray = file($fileName); - foreach($fileLineArray as $fileLine) { - $dataLine = trim($fileLine); - $delimiter = strpos($dataLine, '='); - if ($delimiter > 0) { - $key = strtolower(trim(substr($dataLine, 0, $delimiter))); - $value = trim(substr($dataLine, $delimiter + 1)); - $iniSetting[$key] = $value; - } - } - - return $iniSetting; - } - - function help() { - echo "Usage: php bake2.php task [param1, ...]\n"; - } -} -?> \ No newline at end of file diff --git a/cake/console/libs/shell.php b/cake/console/libs/shell.php index 155ba538a..f115bfb82 100644 --- a/cake/console/libs/shell.php +++ b/cake/console/libs/shell.php @@ -123,12 +123,18 @@ class Shell extends Object { * Initializes the Shell * can be overriden in subclasses * - * @return null + * @return void */ function initialize() { - $this->_loadModels(); - + $this->_welcome(); + } +/** + * Displays a header for the shell + * + * @return void + */ + function _welcome() { $this->hr(); $this->out('App : '. APP_DIR); $this->out('Path: '. ROOT . DS . APP_DIR);