From 4c9a9ebb31cc5ca4fa7f423ee57de7c12e216bff Mon Sep 17 00:00:00 2001 From: gwoo Date: Tue, 15 May 2007 01:16:10 +0000 Subject: [PATCH] updating shell paths and help git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5099 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/console/cake.php | 40 +++++++++++++++++-------------------- cake/console/libs/shell.php | 13 ++++++------ 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/cake/console/cake.php b/cake/console/cake.php index 52e8b4164..d01299e69 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -237,7 +237,7 @@ class ShellDispatcher { */ function dispatch() { $this->stdout("\nWelcome to CakePHP v" . Configure::version() . " Console"); - + $this->stdout("---------------------------------------------------------------"); $protectedCommands = array('initialize', 'main','in','out','err','hr', 'createFile', 'isDir','copyDir','Object','toString', 'requestAction','log','cakeError', 'ShellDispatcher', @@ -404,38 +404,29 @@ class ShellDispatcher { $app = 'app'; $root = dirname(dirname(dirname(__FILE__))); - $working = dirname(dirname(dirname(__FILE__))); if(!empty($this->params['working'])) { + $root = dirname($this->params['working']); $app = basename($this->params['working']); - $working = dirname($this->params['working']) . DS . basename($this->params['working']); - $root = dirname($working); - unset($this->params['working']); } if(!empty($this->params['app'])) { if($this->params['app']{0} == '/') { + $root = dirname($this->params['app']); $app = basename($this->params['app']); - $working = $this->params['app']; } else { + $root = $root . DS . $app; $app = $this->params['app']; } - unset($this->params['app']); } - if(empty($this->params['app']) && in_array($app, array('cake', 'console', 'app'))){ + + if(in_array($app, array('cake', 'console')) || realpath($root.DS.$app) === dirname(dirname(dirname(__FILE__)))) { + $root = dirname(dirname(dirname(__FILE__))); $app = 'app'; - $working = dirname(dirname(__FILE__)); } - if($app !== basename($working) && realpath($working) !== dirname(dirname(__FILE__))) { - $root = $working; - } - - if($app === basename($working) && realpath($working) === dirname(dirname(dirname(__FILE__)))) { - $app = 'app'; - $root = $working; - } + $working = $root . DS . $app; $this->params = array_merge(array('app'=> $app, 'root'=> $root, 'working'=> $working), $this->params); } @@ -458,13 +449,18 @@ class ShellDispatcher { * @return void */ function help() { - $this->stdout("\nPaths:"); + $this->stdout("Current Paths:"); $this->stdout(" -working: " . $this->params['working']); $this->stdout(" -root: " . ROOT); $this->stdout(" -app: ". APP); $this->stdout(" -core: " . CORE_PATH); + $this->stdout(""); + $this->stdout("Changing Paths:"); + $this->stdout("your working path should be the same as your application path"); + $this->stdout("to change your path use the '-app' param."); + $this->stdout("Example: -app relative/path/to/myapp or -app /absolute/path/to/myapp"); - $this->stdout("\nAvailable Scripts:"); + $this->stdout("\nAvailable Shells:"); foreach($this->shellPaths as $path) { if(is_dir($path)) { $shells = listClasses($path); @@ -475,14 +471,14 @@ class ShellDispatcher { } else { foreach ($shells as $shell) { if ($shell != 'shell.php') { - $this->stdout("\t - " . r('.php', '', $shell)); + $this->stdout("\t " . r('.php', '', $shell)); } } } } } - $this->stdout("\nTo run a command, type 'cake script_name [args]'"); - $this->stdout("To get help on a specific command, type 'cake script_name help'"); + $this->stdout("\nTo run a command, type 'cake shell_name [args]'"); + $this->stdout("To get help on a specific command, type 'cake shell_name help'"); exit(); } } diff --git a/cake/console/libs/shell.php b/cake/console/libs/shell.php index 877c9cd33..ab5b32235 100644 --- a/cake/console/libs/shell.php +++ b/cake/console/libs/shell.php @@ -143,7 +143,6 @@ class Shell extends Object { * @return void */ function _welcome() { - $this->hr(); $this->out('App : '. APP_DIR); $this->out('Path: '. ROOT . DS . APP_DIR); $this->hr(); @@ -229,7 +228,7 @@ class Shell extends Object { } $this->taskClass = $tasks[0]; - + foreach($tasks as $taskName) { $taskKey = Inflector::underscore($taskName); $loaded = false; @@ -240,20 +239,20 @@ class Shell extends Object { break; } } - + if ($loaded) { $taskClass = Inflector::camelize($taskName.'Task'); if(!class_exists($taskClass)) { require_once $taskPath; } - + if(class_exists($taskClass) && !isset($this->{$taskName})) { $task =& new $taskClass($this->Dispatch); $this->taskNames[] = $taskName; $this->{$taskName} =& $task; ClassRegistry::addObject($taskKey, $task); - } - + } + if(!isset($this->{$taskName})) { $this->err("Task '".$taskName."' could not be loaded"); exit(); @@ -496,6 +495,6 @@ class Shell extends Object { */ function _pluralHumanName($name) { return Inflector::humanize(Inflector::underscore(Inflector::pluralize($name))); - } + } } ?> \ No newline at end of file