Browse Source

Logging shell aliasing conflicts

Jose Lorenzo Rodriguez 11 years ago
parent
commit
65e8bcbeb9
1 changed files with 17 additions and 1 deletions
  1. 17 1
      src/Console/ShellDispatcher.php

+ 17 - 1
src/Console/ShellDispatcher.php

@@ -14,11 +14,13 @@
  */
 namespace Cake\Console;
 
+use Cake\Console\ConsoleIo;
 use Cake\Console\Exception\MissingShellException;
 use Cake\Core\App;
 use Cake\Core\Configure;
 use Cake\Core\Exception\Exception;
 use Cake\Core\Plugin;
+use Cake\Log\Log;
 use Cake\Shell\Task\CommandTask;
 use Cake\Utility\Inflector;
 
@@ -193,7 +195,9 @@ class ShellDispatcher {
 	public function addShortPluginAliases() {
 		$plugins = Plugin::loaded();
 
-		$task = new CommandTask();
+		$io = new ConsoleIo();
+		$task = new CommandTask($io);
+		$io->setLoggers(false);
 		$list = $task->getShellList();
 		$fixed = array_flip($list['app']) + array_flip($list['CORE']);
 		$aliases = [];
@@ -204,12 +208,24 @@ class ShellDispatcher {
 			}
 
 			foreach ($list[$plugin] as $shell) {
+				if (isset($aliases[$shell])) {
+					$other = $aliased[$shell];
+					Log::write(
+						'debug',
+						"command '$shell' in plugin '$plugin' was not aliased, conflicts with '$other'",
+						['console']
+					);
+				}
 				$aliases += [$shell => $plugin];
 			}
 		}
 
 		foreach ($aliases as $shell => $plugin) {
 			if (isset($fixed[$shell])) {
+				Log::write(
+					'debug',
+					"command '$shell' in plugin '$plugin' was not aliased, conflicts with another shell"
+				);
 				continue;
 			}
 			static::alias($shell, "$plugin.$shell");