Skip to content
Permalink
Browse files

Allowing plugin shells to be called without plugin notation

Plugin shells will not require a plugin notation prefix anynmore
given that there are no shell name conflicts
  • Loading branch information...
lorenzo committed Sep 13, 2014
1 parent 6f0347f commit e7357f9721cb40a6250a2912132ae7c90663f092
Showing with 21 additions and 2 deletions.
  1. +21 −2 src/Console/ShellDispatcher.php
@@ -20,6 +20,7 @@
use Cake\Core\Exception\Exception;
use Cake\Core\Plugin;
use Cake\Utility\Inflector;
use Cake\Shell\Task\CommandTask;
/**
* Shell dispatcher handles dispatching cli commands.
@@ -185,15 +186,33 @@ protected function _dispatch() {
* For all loaded plugins, add a short alias
*
* This permits a plugin which implements a shell of the same name to be accessed
* Using the plugin name alone
* Using the shell name alone
*
* @return void
*/
public function addShortPluginAliases() {
$plugins = Plugin::loaded();
$task = new CommandTask();
$list = $task->getShellList();
$fixed = array_flip($list['app']) + array_flip($list['CORE']);
$aliases = [];
foreach ($plugins as $plugin) {
self::alias($plugin, "$plugin.$plugin");
if (!isset($list[$plugin])) {
continue;
}
foreach ($list[$plugin] as $shell) {
$aliases += [$shell => $plugin];
}
}
foreach ($aliases as $shell => $plugin) {
if (isset($fixed[$shell])) {
continue;
}
static::alias($shell, "$plugin.$shell");
}
}

3 comments on commit e7357f9

@jadb

This comment has been minimized.

Copy link
Member

jadb replied Sep 21, 2014

When one does not have app-specific shells, it breaks with undefined 'app' key error (because CommandTask::getShellList() returns a filtered array).

@lorenzo

This comment has been minimized.

Copy link
Member Author

lorenzo replied Sep 21, 2014

@jadb would you be able to send a fix for this?

@jadb

This comment has been minimized.

Copy link
Member

jadb replied Sep 21, 2014

Done, see #4683

Please sign in to comment.
You can’t perform that action at this time.