Skip to content
This repository
Browse code

Make input prompt clearer in extract task.

Make the prompt display the paths that will be scanned.  Hopefully
this makes the shell a bit easier to use and understand. Also
make the shell not accept 0 paths as a correct answer.

Fixes #2877
  • Loading branch information...
commit 8103eae9f114d428f7c4d1cb038c53baad5b0abc 1 parent 15a7472
Mark Story authored May 12, 2012
51  lib/Cake/Console/Command/Task/ExtractTask.php
@@ -105,6 +105,38 @@ class ExtractTask extends AppShell {
105 105
 	protected $_validationDomain = 'default';
106 106
 
107 107
 /**
  108
+ * Method to interact with the User and get path selections.
  109
+ *
  110
+ * @return void
  111
+ */
  112
+	protected function _getPaths() {
  113
+		$defaultPath = APP;
  114
+		while (true) {
  115
+			$currentPaths = count($this->_paths) > 0 ? $this->_paths : array('None');
  116
+			$message = __d(
  117
+				'cake_console',
  118
+				"Current paths: %s\nWhat is the path you would like to extract?\n[Q]uit [D]one",
  119
+				implode(', ', $currentPaths)
  120
+			);
  121
+			$response = $this->in($message, null, $defaultPath);
  122
+			if (strtoupper($response) === 'Q') {
  123
+				$this->out(__d('cake_console', 'Extract Aborted'));
  124
+				return $this->_stop();
  125
+			} elseif (strtoupper($response) === 'D' && count($this->_paths)) {
  126
+				$this->out();
  127
+				return;
  128
+			} elseif (strtoupper($response) === 'D') {
  129
+				$this->err(__d('cake_console', '<warning>No directories selected.</warning> Please choose a directory.'));
  130
+			} elseif (is_dir($response)) {
  131
+				$this->_paths[] = $response;
  132
+				$defaultPath = 'D';
  133
+			} else {
  134
+				$this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.'));
  135
+			}
  136
+			$this->out();
  137
+		}
  138
+	}
  139
+/**
108 140
  * Execution method always used for tasks
109 141
  *
110 142
  * @return void
@@ -126,24 +158,7 @@ public function execute() {
126 158
 			$this->_paths = array(CakePlugin::path($plugin));
127 159
 			$this->params['plugin'] = $plugin;
128 160
 		} else {
129  
-			$defaultPath = APP;
130  
-			$message = __d('cake_console', "What is the path you would like to extract?\n[Q]uit [D]one");
131  
-			while (true) {
132  
-				$response = $this->in($message, null, $defaultPath);
133  
-				if (strtoupper($response) === 'Q') {
134  
-					$this->out(__d('cake_console', 'Extract Aborted'));
135  
-					$this->_stop();
136  
-				} elseif (strtoupper($response) === 'D') {
137  
-					$this->out();
138  
-					break;
139  
-				} elseif (is_dir($response)) {
140  
-					$this->_paths[] = $response;
141  
-					$defaultPath = 'D';
142  
-				} else {
143  
-					$this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.'));
144  
-				}
145  
-				$this->out();
146  
-			}
  161
+			$this->_getPaths();
147 162
 		}
148 163
 
149 164
 		if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) {

0 notes on commit 8103eae

Please sign in to comment.
Something went wrong with that request. Please try again.