not fully complete changes but adding so we can change from Script to Shell

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5054 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2007-05-12 19:47:14 +00:00
parent bde2f70753
commit f1bf1fa6ee
2 changed files with 27 additions and 17 deletions

View file

@ -232,7 +232,8 @@ class ConsoleDispatcher {
*/ */
function dispatch() { function dispatch() {
$this->stdout("\nWelcome to CakePHP v" . Configure::version() . " Console"); $this->stdout("\nWelcome to CakePHP v" . Configure::version() . " Console");
if (!isset($this->args[0]) || $this->args[0] != 'help') {
if (!isset($this->args[0]) || (isset($this->args[0]) && $this->args[0] != 'help')) {
$this->stdout("Type 'cake help' for help\n"); $this->stdout("Type 'cake help' for help\n");
} }
$protectedCommands = array('initialize', 'main','in','out','err','hr', $protectedCommands = array('initialize', 'main','in','out','err','hr',
@ -312,14 +313,7 @@ class ConsoleDispatcher {
} }
} }
} else { } else {
$this->stdout('Available Scripts:'); $this->help();
foreach (listClasses(CONSOLE_LIBS) as $script) {
if ($script != 'cake_script.php') {
$this->stdout("\t - " . r('.php', '', $script));
}
}
$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'");
} }
} }
/** /**
@ -386,7 +380,6 @@ class ConsoleDispatcher {
$this->args[] = $params[$i]; $this->args[] = $params[$i];
} }
} }
$this->params = array_merge(array('working'=> dirname(dirname(dirname(__FILE__)))), $this->params);
$app = 'app'; $app = 'app';
if(isset($this->params['app'])) { if(isset($this->params['app'])) {
@ -396,7 +389,9 @@ class ConsoleDispatcher {
$app = $this->params['app']; $app = $this->params['app'];
} }
} }
$this->params['working'] = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . $app; if(empty($this->params['working'])) {
$this->params['working'] = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . $app;
}
} }
/** /**
* Removes first argument and shifts other arguments up * Removes first argument and shifts other arguments up
@ -417,12 +412,23 @@ class ConsoleDispatcher {
* @return void * @return void
*/ */
function help() { function help() {
$this->stdout("\nConsole Help:");
$this->stdout('-------------');
echo 'Args ';
print_r($this->args); print_r($this->args);
echo 'Params '; $this->stdout("\nPaths:");
print_r($this->params); $this->stdout(" -working: " . $this->params['working']);
$this->stdout(" -app: ". APP_DIR);
$this->stdout(" -cake: " . CORE_PATH);
$this->stdout("\nAvailable Scripts:");
foreach($this->scriptPaths as $path) {
$this->stdout("\n " . $path . ":");
foreach (listClasses($path) as $script) {
if ($script != 'cake_script.php') {
$this->stdout("\t - " . r('.php', '', $script));
}
}
}
$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'");
} }
} }
if (!defined('DISABLE_AUTO_DISPATCH')) { if (!defined('DISABLE_AUTO_DISPATCH')) {

View file

@ -84,8 +84,12 @@ class CakeScript extends Object {
*/ */
function initialize() { function initialize() {
if($this->_loadDbConfig()) { if($this->_loadDbConfig()) {
$this->_loadModel(); //$this->_loadModel();
} }
$this->hr();
$this->out('Name: '. APP_DIR);
$this->out('Path: '. ROOT . DS . APP_DIR);
$this->hr();
} }
/** /**
* Loads database file and constructs DATABASE_CONFIG class * Loads database file and constructs DATABASE_CONFIG class