Skip to content

Commit e7357f9

Browse files
committed
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
1 parent 6f0347f commit e7357f9

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/Console/ShellDispatcher.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Cake\Core\Exception\Exception;
2121
use Cake\Core\Plugin;
2222
use Cake\Utility\Inflector;
23+
use Cake\Shell\Task\CommandTask;
2324

2425
/**
2526
* Shell dispatcher handles dispatching cli commands.
@@ -185,15 +186,33 @@ protected function _dispatch() {
185186
* For all loaded plugins, add a short alias
186187
*
187188
* This permits a plugin which implements a shell of the same name to be accessed
188-
* Using the plugin name alone
189+
* Using the shell name alone
189190
*
190191
* @return void
191192
*/
192193
public function addShortPluginAliases() {
193194
$plugins = Plugin::loaded();
194195

196+
$task = new CommandTask();
197+
$list = $task->getShellList();
198+
$fixed = array_flip($list['app']) + array_flip($list['CORE']);
199+
$aliases = [];
200+
195201
foreach ($plugins as $plugin) {
196-
self::alias($plugin, "$plugin.$plugin");
202+
if (!isset($list[$plugin])) {
203+
continue;
204+
}
205+
206+
foreach ($list[$plugin] as $shell) {
207+
$aliases += [$shell => $plugin];
208+
}
209+
}
210+
211+
foreach ($aliases as $shell => $plugin) {
212+
if (isset($fixed[$shell])) {
213+
continue;
214+
}
215+
static::alias($shell, "$plugin.$shell");
197216
}
198217
}
199218

0 commit comments

Comments
 (0)