Browse Source

Remove one of the interactive questions in plugin bake.

Bake is becoming less interactive as it makes the code less complex to
work with and easier to maintain/use (imo).
mark_story 12 years ago
parent
commit
1b09fb7fbf

+ 11 - 23
src/Console/Command/Task/PluginTask.php

@@ -15,6 +15,7 @@
 namespace Cake\Console\Command\Task;
 
 use Cake\Console\Command\Task\BakeTask;
+use Cake\Console\Shell;
 use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Utility\ConventionsTrait;
@@ -57,31 +58,18 @@ class PluginTask extends BakeTask {
  * @return void
  */
 	public function execute() {
-		if (isset($this->args[0])) {
-			$plugin = $this->_camelize($this->args[0]);
-			$pluginPath = $this->_pluginPath($plugin);
-			if (is_dir($pluginPath)) {
-				$this->out(__d('cake_console', 'Plugin: %s already exists, no action taken', $plugin));
-				$this->out(__d('cake_console', 'Path: %s', $pluginPath));
-				return false;
-			}
-			$this->_interactive($plugin);
-		} else {
-			return $this->_interactive();
+		if (empty($this->args[0])) {
+			$this->err('<error>You must provide a plugin name in CamelCase format.</error>');
+			$this->err('To make an "Example" plugin, run <info>Console/cake bake plugin Example</info>.');
+			return false;
 		}
-	}
-
-/**
- * Interactive interface
- *
- * @param string $plugin
- * @return void
- */
-	protected function _interactive($plugin = null) {
-		while ($plugin === null) {
-			$plugin = $this->in(__d('cake_console', 'Enter the name of the plugin in CamelCase format'));
+		$plugin = $this->_camelize($this->args[0]);
+		$pluginPath = $this->_pluginPath($plugin);
+		if (is_dir($pluginPath)) {
+			$this->out(__d('cake_console', 'Plugin: %s already exists, no action taken', $plugin));
+			$this->out(__d('cake_console', 'Path: %s', $pluginPath));
+			return false;
 		}
-
 		if (!$this->bake($plugin)) {
 			$this->error(__d('cake_console', "An error occurred trying to bake: %s in %s", $plugin, $this->path . $plugin));
 		}

+ 5 - 17
tests/TestCase/Console/Command/Task/PluginTaskTest.php

@@ -114,27 +114,15 @@ class PluginTaskTest extends TestCase {
  * @return void
  */
 	public function testExecuteWithNoArgs() {
-		$this->Task->expects($this->at(0))
-			->method('in')
-			->will($this->returnValue('TestPlugin'));
-
-		$this->Task->expects($this->at(1))
-			->method('in')
-			->will($this->returnValue('y'));
-
 		$path = $this->Task->path . 'TestPlugin';
 		$file = $path . DS . 'Controller' . DS . 'TestPluginAppController.php';
 
-		$this->Task->expects($this->at(2))->method('createFile')
-			->with($file, new \PHPUnit_Framework_Constraint_IsAnything());
-
-		$file = $path . DS . 'phpunit.xml';
-		$this->Task->expects($this->at(3))->method('createFile')
-			->with($file, new \PHPUnit_Framework_Constraint_IsAnything());
+		$this->Task->expects($this->at(0))
+			->method('err')
+			->with($this->stringContains('You must'));
 
-		$file = $path . DS . 'Test' . DS . 'bootstrap.php';
-		$this->Task->expects($this->at(4))->method('createFile')
-			->with($file, new \PHPUnit_Framework_Constraint_IsAnything());
+		$this->Task->expects($this->never())
+			->method('createFile');
 
 		$this->Task->args = array();
 		$this->Task->execute();