From 8103eae9f114d428f7c4d1cb038c53baad5b0abc Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 May 2012 20:18:10 -0400 Subject: [PATCH] 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 --- lib/Cake/Console/Command/Task/ExtractTask.php | 51 ++++++++++++------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index e791a44b5..abebb840a 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -104,6 +104,38 @@ class ExtractTask extends AppShell { */ protected $_validationDomain = 'default'; +/** + * Method to interact with the User and get path selections. + * + * @return void + */ + protected function _getPaths() { + $defaultPath = APP; + while (true) { + $currentPaths = count($this->_paths) > 0 ? $this->_paths : array('None'); + $message = __d( + 'cake_console', + "Current paths: %s\nWhat is the path you would like to extract?\n[Q]uit [D]one", + implode(', ', $currentPaths) + ); + $response = $this->in($message, null, $defaultPath); + if (strtoupper($response) === 'Q') { + $this->out(__d('cake_console', 'Extract Aborted')); + return $this->_stop(); + } elseif (strtoupper($response) === 'D' && count($this->_paths)) { + $this->out(); + return; + } elseif (strtoupper($response) === 'D') { + $this->err(__d('cake_console', 'No directories selected. Please choose a directory.')); + } elseif (is_dir($response)) { + $this->_paths[] = $response; + $defaultPath = 'D'; + } else { + $this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.')); + } + $this->out(); + } + } /** * Execution method always used for tasks * @@ -126,24 +158,7 @@ class ExtractTask extends AppShell { $this->_paths = array(CakePlugin::path($plugin)); $this->params['plugin'] = $plugin; } else { - $defaultPath = APP; - $message = __d('cake_console', "What is the path you would like to extract?\n[Q]uit [D]one"); - while (true) { - $response = $this->in($message, null, $defaultPath); - if (strtoupper($response) === 'Q') { - $this->out(__d('cake_console', 'Extract Aborted')); - $this->_stop(); - } elseif (strtoupper($response) === 'D') { - $this->out(); - break; - } elseif (is_dir($response)) { - $this->_paths[] = $response; - $defaultPath = 'D'; - } else { - $this->err(__d('cake_console', 'The directory path you supplied was not found. Please try again.')); - } - $this->out(); - } + $this->_getPaths(); } if (!empty($this->params['exclude-plugins']) && $this->_isExtractingApp()) {