Skip to content

Commit

Permalink
Making shells return help if a ConsoleException is catched, like when…
Browse files Browse the repository at this point in the history
… passing bad parameters
  • Loading branch information
lorenzo committed Apr 22, 2011
1 parent 495611b commit fa1d7da
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions lib/Cake/Console/ShellDispatcher.php
Expand Up @@ -171,25 +171,30 @@ public function dispatch() {
$command = $this->args[0];
}

if ($Shell instanceof Shell) {
$Shell->initialize();
$Shell->loadTasks();
return $Shell->runCommand($command, $this->args);
}
$methods = array_diff(get_class_methods($Shell), get_class_methods('Shell'));
$added = in_array($command, $methods);
$private = $command[0] == '_' && method_exists($Shell, $command);

if (!$private) {
if ($added) {
$this->shiftArgs();
$Shell->startup();
return $Shell->{$command}();
try {
if ($Shell instanceof Shell) {
$Shell->initialize();
$Shell->loadTasks();
return $Shell->runCommand($command, $this->args);
}
if (method_exists($Shell, 'main')) {
$Shell->startup();
return $Shell->main();
$methods = array_diff(get_class_methods($Shell), get_class_methods('Shell'));
$added = in_array($command, $methods);
$private = $command[0] == '_' && method_exists($Shell, $command);

if (!$private) {
if ($added) {
$this->shiftArgs();
$Shell->startup();
return $Shell->{$command}();
}
if (method_exists($Shell, 'main')) {
$Shell->startup();
return $Shell->main();
}
}
} catch(ConsoleException $e) {
$this->help();
$this->_stop(1);
}
throw new MissingShellMethodException(array('shell' => $shell, 'method' => $arg));
}
Expand Down

0 comments on commit fa1d7da

Please sign in to comment.