Making shells return help if a ConsoleException is catched, like when passing bad parameters

This commit is contained in:
Jose Lorenzo Rodriguez 2011-04-22 16:08:26 -04:30
parent 495611b313
commit fa1d7da56e

View file

@ -171,25 +171,30 @@ class ShellDispatcher {
$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);
try {
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}();
}
if (method_exists($Shell, 'main')) {
$Shell->startup();
return $Shell->main();
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));
}