Navigation Menu

Skip to content

Commit

Permalink
Made _stop() usage in Consoles / Tasks more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
tersmitten committed Jul 1, 2013
1 parent 54ca435 commit dad1f16
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/AclShell.php
Expand Up @@ -82,7 +82,7 @@ public function startup() {
$out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n";
$out .= "--------------------------------------------------\n";
$this->err($out);
$this->_stop();
return $this->_stop();
}

if ($this->command) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/ApiShell.php
Expand Up @@ -100,7 +100,7 @@ public function main() {
if (isset($this->params['method'])) {
if (!isset($parsed[$this->params['method']])) {
$this->err(__d('cake_console', '%s::%s() could not be found', $class, $this->params['method']));
$this->_stop();
return $this->_stop();
}
$method = $parsed[$this->params['method']];
$this->out($class . '::' . $method['method'] . $method['parameters']);
Expand Down
20 changes: 10 additions & 10 deletions lib/Cake/Console/Command/SchemaShell.php
Expand Up @@ -106,11 +106,11 @@ public function view() {
$File = new File($this->Schema->path . DS . $this->params['file']);
if ($File->exists()) {
$this->out($File->read());
$this->_stop();
return $this->_stop();
} else {
$file = $this->Schema->path . DS . $this->params['file'];
$this->err(__d('cake_console', 'Schema file (%s) could not be found.', $file));
$this->_stop();
return $this->_stop();
}
}

Expand Down Expand Up @@ -184,10 +184,10 @@ public function generate() {

if ($this->Schema->write($content)) {
$this->out(__d('cake_console', 'Schema file: %s generated', $content['file']));
$this->_stop();
return $this->_stop();
} else {
$this->err(__d('cake_console', 'Schema file: %s generated'));
$this->_stop();
return $this->_stop();
}
}

Expand All @@ -205,7 +205,7 @@ public function dump() {
$Schema = $this->Schema->load();
if (!$Schema) {
$this->err(__d('cake_console', 'Schema could not be loaded'));
$this->_stop();
return $this->_stop();
}
if (!empty($this->params['write'])) {
if ($this->params['write'] == 1) {
Expand All @@ -229,10 +229,10 @@ public function dump() {

if ($File->write($contents)) {
$this->out(__d('cake_console', 'SQL dump file created in %s', $File->pwd()));
$this->_stop();
return $this->_stop();
} else {
$this->err(__d('cake_console', 'SQL dump could not be created'));
$this->_stop();
return $this->_stop();
}
}
$this->out($contents);
Expand Down Expand Up @@ -290,7 +290,7 @@ protected function _loadSchema() {
$this->err(__d('cake_console', 'The chosen schema could not be loaded. Attempted to load:'));
$this->err(__d('cake_console', 'File: %s', $this->Schema->path . DS . $this->Schema->file));
$this->err(__d('cake_console', 'Name: %s', $this->Schema->name));
$this->_stop();
return $this->_stop();
}
$table = null;
if (isset($this->args[1])) {
Expand Down Expand Up @@ -323,7 +323,7 @@ protected function _create(CakeSchema $Schema, $table = null) {
}
if (empty($drop) || empty($create)) {
$this->out(__d('cake_console', 'Schema is up to date.'));
$this->_stop();
return $this->_stop();
}

$this->out("\n" . __d('cake_console', 'The following table(s) will be dropped.'));
Expand Down Expand Up @@ -375,7 +375,7 @@ protected function _update(&$Schema, $table = null) {

if (empty($contents)) {
$this->out(__d('cake_console', 'Schema is up to date.'));
$this->_stop();
return $this->_stop();
}

$this->out("\n" . __d('cake_console', 'The following statements will run.'));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ControllerTask.php
Expand Up @@ -289,7 +289,7 @@ public function bakeActions($controllerName, $admin = null, $wannaUseSession = t
App::uses($modelImport, $plugin . 'Model');
if (!class_exists($modelImport)) {
$this->err(__d('cake_console', 'You must have a model for this class to build basic methods. Please try again.'));
$this->_stop();
return $this->_stop();
}

$modelObj = ClassRegistry::init($currentModelName);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/DbConfigTask.php
Expand Up @@ -77,7 +77,7 @@ public function initialize() {
public function execute() {
if (empty($this->args)) {
$this->_interactive();
$this->_stop();
return $this->_stop();
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ExtractTask.php
Expand Up @@ -207,7 +207,7 @@ public function execute() {
$response = $this->in($message, null, rtrim($this->_paths[0], DS) . DS . 'Locale');
if (strtoupper($response) === 'Q') {
$this->out(__d('cake_console', 'Extract Aborted'));
$this->_stop();
return $this->_stop();
} elseif ($this->_isPathUsable($response)) {
$this->_output = $response . DS;
break;
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/Task/ModelTask.php
Expand Up @@ -911,7 +911,7 @@ public function getAllTables($useDbConfig = null) {
}
if (empty($tables)) {
$this->err(__d('cake_console', 'Your database does not have any tables.'));
$this->_stop();
return $this->_stop();
}
return $tables;
}
Expand All @@ -933,7 +933,7 @@ public function getName($useDbConfig = null) {

if ($enteredModel === 'q') {
$this->out(__d('cake_console', 'Exit'));
$this->_stop();
return $this->_stop();
}

if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ProjectTask.php
Expand Up @@ -417,7 +417,7 @@ public function getPrefix() {
$this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.',
'Configure::write(\'Routing.prefixes\', array(\'admin\'))',
'/app/Config/core.php'));
$this->_stop();
return $this->_stop();
}
return $admin . '_';
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/Task/ViewTask.php
Expand Up @@ -267,7 +267,7 @@ protected function _loadController() {
if (!class_exists($controllerClassName)) {
$file = $controllerClassName . '.php';
$this->err(__d('cake_console', "The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file));
$this->_stop();
return $this->_stop();
}
$controllerObj = new $controllerClassName();
$controllerObj->plugin = $this->plugin;
Expand Down Expand Up @@ -334,7 +334,7 @@ public function customAction() {
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y');
if (strtolower($looksGood) === 'y') {
$this->bake($action, ' ');
$this->_stop();
return $this->_stop();
} else {
$this->out(__d('cake_console', 'Bake Aborted.'));
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/ConsoleErrorHandler.php
Expand Up @@ -60,7 +60,7 @@ public function handleException(Exception $exception) {
$exception->getMessage(),
$exception->getTraceAsString()
));
$this->_stop($exception->getCode() ? $exception->getCode() : 1);
return $this->_stop($exception->getCode() ? $exception->getCode() : 1);
}

/**
Expand Down Expand Up @@ -88,7 +88,7 @@ public function handleError($code, $description, $file = null, $line = null, $co
}

if ($log === LOG_ERR) {
$this->_stop(1);
return $this->_stop(1);
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Console/Shell.php
Expand Up @@ -504,7 +504,7 @@ protected function _getInput($prompt, $options, $default) {
$result = $this->stdin->read();

if ($result === false) {
$this->_stop(1);
return $this->_stop(1);
}
$result = trim($result);

Expand Down Expand Up @@ -618,7 +618,7 @@ public function error($title, $message = null) {
if (!empty($message)) {
$this->err($message);
}
$this->_stop(1);
return $this->_stop(1);
}

/**
Expand Down Expand Up @@ -656,7 +656,7 @@ public function createFile($path, $contents) {

if (strtolower($key) === 'q') {
$this->out(__d('cake_console', '<error>Quitting</error>.'), 2);
$this->_stop();
return $this->_stop();
} elseif (strtolower($key) !== 'y') {
$this->out(__d('cake_console', 'Skip `%s`', $path), 2);
return false;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/ShellDispatcher.php
Expand Up @@ -65,7 +65,7 @@ public function __construct($args = array(), $bootstrap = true) {
*/
public static function run($argv) {
$dispatcher = new ShellDispatcher($argv);
$dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
return $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
}

/**
Expand Down

0 comments on commit dad1f16

Please sign in to comment.