From c1d99017e97da98e94702b89740492e539bf7dd4 Mon Sep 17 00:00:00 2001 From: evilbloodydemon Date: Sat, 11 Dec 2010 18:14:54 +0300 Subject: [PATCH] upgrade shell - option to specify extensions --- cake/console/shells/upgrade.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/cake/console/shells/upgrade.php b/cake/console/shells/upgrade.php index 78957d6e5..9f51b1bef 100644 --- a/cake/console/shells/upgrade.php +++ b/cake/console/shells/upgrade.php @@ -71,17 +71,22 @@ class UpgradeShell extends Shell { $this->_paths = array(App::pluginPath($this->params['plugin'])); } - $this->_findFiles(); + $extensions = 'php|ctp|thtml|inc|tpl'; + if (!empty($this->params['ext'])) { + $extensions = $this->params['ext']; + } + + $this->_findFiles($extensions); foreach ($this->_files as $file) { $this->out('Updating ' . $file . '...', 1, Shell::VERBOSE); $this->_updateFile($file, $patterns); } } - protected function _findFiles($pattern = '') { + protected function _findFiles($extensions = '', $pattern = '') { foreach ($this->_paths as $path) { $Folder = new Folder($path); - $files = $Folder->findRecursive('.*\.(php|ctp|thtml|inc|tpl)', true); + $files = $Folder->findRecursive(".*\.($extensions)", true); if (!empty($pattern)) { foreach ($files as $i => $file) { if (preg_match($pattern, $file)) { @@ -117,22 +122,21 @@ class UpgradeShell extends Shell { * @return void */ function getOptionParser() { + $subcommandParser = array( + 'options' => array( + 'plugin' => array('short' => 'p', 'help' => __('The plugin to update.')), + 'ext' => array('short' => 'e', 'help' => __('The extension(s) to search.')), + ) + ); + return parent::getOptionParser() ->addSubcommand('i18n', array( 'help' => 'Update the i18n translation method calls.', - 'parser' => array( - 'options' => array( - 'plugin' => array('short' => 'p', 'help' => __('The plugin to update.')) - ) - ) + 'parser' => $subcommandParser )) ->addSubcommand('helpers', array( 'help' => 'Update calls to helpers.', - 'parser' => array( - 'options' => array( - 'plugin' => array('short' => 'p', 'help' => __('The plugin to update.')) - ) - ) + 'parser' => $subcommandParser )); } } \ No newline at end of file