Browse Source

Made _stop() usage in Consoles / Tasks more consistent

Mischa ter Smitten 12 years ago
parent
commit
dad1f16eaf

+ 1 - 1
lib/Cake/Console/Command/AclShell.php

@@ -82,7 +82,7 @@ class AclShell extends AppShell {
 			$out .= __d('cake_console', 'Current ACL Classname: %s', $class) . "\n";
 			$out .= "--------------------------------------------------\n";
 			$this->err($out);
-			$this->_stop();
+			return $this->_stop();
 		}
 
 		if ($this->command) {

+ 1 - 1
lib/Cake/Console/Command/ApiShell.php

@@ -100,7 +100,7 @@ class ApiShell extends AppShell {
 			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']);

+ 10 - 10
lib/Cake/Console/Command/SchemaShell.php

@@ -106,11 +106,11 @@ class SchemaShell extends AppShell {
 		$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();
 		}
 	}
 
@@ -184,10 +184,10 @@ class SchemaShell extends AppShell {
 
 		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();
 		}
 	}
 
@@ -205,7 +205,7 @@ class SchemaShell extends AppShell {
 		$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) {
@@ -229,10 +229,10 @@ class SchemaShell extends AppShell {
 
 			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);
@@ -290,7 +290,7 @@ class SchemaShell extends AppShell {
 			$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])) {
@@ -323,7 +323,7 @@ class SchemaShell extends AppShell {
 		}
 		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.'));
@@ -375,7 +375,7 @@ class SchemaShell extends AppShell {
 
 		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.'));

+ 1 - 1
lib/Cake/Console/Command/Task/ControllerTask.php

@@ -289,7 +289,7 @@ class ControllerTask extends BakeTask {
 		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);

+ 1 - 1
lib/Cake/Console/Command/Task/DbConfigTask.php

@@ -77,7 +77,7 @@ class DbConfigTask extends AppShell {
 	public function execute() {
 		if (empty($this->args)) {
 			$this->_interactive();
-			$this->_stop();
+			return $this->_stop();
 		}
 	}
 

+ 1 - 1
lib/Cake/Console/Command/Task/ExtractTask.php

@@ -207,7 +207,7 @@ class ExtractTask extends AppShell {
 				$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;

+ 2 - 2
lib/Cake/Console/Command/Task/ModelTask.php

@@ -911,7 +911,7 @@ class ModelTask extends BakeTask {
 		}
 		if (empty($tables)) {
 			$this->err(__d('cake_console', 'Your database does not have any tables.'));
-			$this->_stop();
+			return $this->_stop();
 		}
 		return $tables;
 	}
@@ -933,7 +933,7 @@ class ModelTask extends BakeTask {
 
 			if ($enteredModel === 'q') {
 				$this->out(__d('cake_console', 'Exit'));
-				$this->_stop();
+				return $this->_stop();
 			}
 
 			if (!$enteredModel || intval($enteredModel) > count($this->_modelNames)) {

+ 1 - 1
lib/Cake/Console/Command/Task/ProjectTask.php

@@ -417,7 +417,7 @@ class ProjectTask extends AppShell {
 				$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 . '_';
 		}

+ 2 - 2
lib/Cake/Console/Command/Task/ViewTask.php

@@ -267,7 +267,7 @@ class ViewTask extends BakeTask {
 		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;
@@ -334,7 +334,7 @@ class ViewTask extends BakeTask {
 		$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.'));
 		}

+ 2 - 2
lib/Cake/Console/ConsoleErrorHandler.php

@@ -60,7 +60,7 @@ class ConsoleErrorHandler {
 			$exception->getMessage(),
 			$exception->getTraceAsString()
 		));
-		$this->_stop($exception->getCode() ? $exception->getCode() : 1);
+		return $this->_stop($exception->getCode() ? $exception->getCode() : 1);
 	}
 
 /**
@@ -88,7 +88,7 @@ class ConsoleErrorHandler {
 		}
 
 		if ($log === LOG_ERR) {
-			$this->_stop(1);
+			return $this->_stop(1);
 		}
 	}
 

+ 3 - 3
lib/Cake/Console/Shell.php

@@ -504,7 +504,7 @@ class Shell extends Object {
 		$result = $this->stdin->read();
 
 		if ($result === false) {
-			$this->_stop(1);
+			return $this->_stop(1);
 		}
 		$result = trim($result);
 
@@ -618,7 +618,7 @@ class Shell extends Object {
 		if (!empty($message)) {
 			$this->err($message);
 		}
-		$this->_stop(1);
+		return $this->_stop(1);
 	}
 
 /**
@@ -656,7 +656,7 @@ class Shell extends Object {
 
 			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;

+ 1 - 1
lib/Cake/Console/ShellDispatcher.php

@@ -65,7 +65,7 @@ class ShellDispatcher {
  */
 	public static function run($argv) {
 		$dispatcher = new ShellDispatcher($argv);
-		$dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
+		return $dispatcher->_stop($dispatcher->dispatch() === false ? 1 : 0);
 	}
 
 /**