Skip to content

Commit

Permalink
upgrade shell - option to specify extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
evilbloodydemon authored and AD7six committed May 1, 2011
1 parent 3dddcf8 commit a7d6970
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions cake/console/shells/upgrade.php
Expand Up @@ -71,17 +71,22 @@ protected function _filesRegexpUpdate($patterns) {
$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)) {
Expand Down Expand Up @@ -117,22 +122,21 @@ protected function _updateFile($file, $patterns) {
* @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
));
}
}

0 comments on commit a7d6970

Please sign in to comment.