Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated the shell given @renansaddam pointers

  • Loading branch information...
commit 5c523a0cd556f0c28bc9b95110318fc92668b927 1 parent 79202ad
@WyriHaximus WyriHaximus authored WyriHaximus committed
Showing with 19 additions and 25 deletions.
  1. +19 −25 lib/Cake/Console/Command/CompletionShell.php
View
44 lib/Cake/Console/Command/CompletionShell.php
@@ -108,43 +108,41 @@ public function fuzzy() {
* @return ConsoleOptionParser
*/
public function getOptionParser() {
- $translationDomain = 'bash_completion';
+ $parser = parent::getOptionParser();
- $parser = AppShell::getOptionParser();
-
- $parser->description(__d($translationDomain, 'Used by bash to autocomplete command name, options and arguments'))
+ $parser->description(__d('cake_console', 'Used by shells like bash to autocomplete command name, options and arguments'))
->addSubcommand('commands', array(
- 'help' => __d($translationDomain, 'Output a list of available commands'),
+ 'help' => __d('cake_console', 'Output a list of available commands'),
'parser' => array(
- 'description' => __d($translationDomain, 'List all availables'),
+ 'description' => __d('cake_console', 'List all availables'),
'arguments' => array(
)
)
))->addSubcommand('subcommands', array(
- 'help' => __d($translationDomain, 'Output a list of available subcommands'),
+ 'help' => __d('cake_console', 'Output a list of available subcommands'),
'parser' => array(
- 'description' => __d($translationDomain, 'List subcommands for a command'),
+ 'description' => __d('cake_console', 'List subcommands for a command'),
'arguments' => array(
'command' => array(
- 'help' => __d($translationDomain, 'The command name'),
+ 'help' => __d('cake_console', 'The command name'),
'required' => true,
)
)
)
))->addSubcommand('options', array(
- 'help' => __d($translationDomain, 'Output a list of available options'),
+ 'help' => __d('cake_console', 'Output a list of available options'),
'parser' => array(
- 'description' => __d($translationDomain, 'List options'),
+ 'description' => __d('cake_console', 'List options'),
'arguments' => array(
'command' => array(
- 'help' => __d($translationDomain, 'The command name'),
+ 'help' => __d('cake_console', 'The command name'),
'required' => false,
)
)
)
))->epilog(
array(
- 'This command is not intended to be called manually',
+ __d('cake_console', 'This command is not intended to be called manually'),
)
);
return $parser;
@@ -162,7 +160,7 @@ protected function _commands() {
$options = array();
foreach ($shellList as $type => $commands) {
$prefix = '';
- if (!in_array($type, array('app', 'core', 'APP', 'CORE'))) {
+ if (!in_array(strtolower($type), array('app', 'core'))) {
$prefix = $type . '.';
}
@@ -187,12 +185,8 @@ protected function _subCommands($commandName) {
return array();
}
- $return = array();
$taskMap = TaskCollection::normalizeObjectArray((array)$Shell->tasks);
- foreach ($taskMap as $task => $properties) {
- $return[] = $task;
- }
-
+ $return = array_keys($taskMap);
$return = array_map('Inflector::underscore', $return);
$ShellReflection = new ReflectionClass('AppShell');
@@ -222,11 +216,11 @@ protected function _subCommands($commandName) {
* @return mixed
*/
protected function _getShell($commandName) {
- list($plugin, $name) = pluginSplit($commandName, true);
+ list($pluginDot, $name) = pluginSplit($commandName, true);
- if ($plugin === 'CORE.' || $plugin === 'APP.' || $plugin === 'core.' || $plugin === 'app.') {
+ if (in_array(strtolower($pluginDot), array('app.', 'core.'))) {
$commandName = $name;
- $plugin = '';
+ $pluginDot = '';
}
if (!in_array($commandName, $this->_commands())) {
@@ -234,12 +228,12 @@ protected function _getShell($commandName) {
}
$name = Inflector::camelize($name);
- $plugin = Inflector::camelize($plugin);
+ $pluginDot = Inflector::camelize($pluginDot);
$class = $name . 'Shell';
- APP::uses($class, $plugin . 'Console/Command');
+ APP::uses($class, $pluginDot . 'Console/Command');
$Shell = new $class();
- $Shell->plugin = trim($plugin, '.');
+ $Shell->plugin = trim($pluginDot, '.');
$Shell->initialize();
$Shell->loadTasks();

0 comments on commit 5c523a0

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