public function helpCommand($commandIdentifier = null)
{
$exceedingArguments = $this->request->getExceedingArguments();
if (count($exceedingArguments) > 0 && $commandIdentifier === null) {
$commandIdentifier = $exceedingArguments[0];
}
if ($commandIdentifier === null) {
$this->displayHelpIndex();
} else {
$matchingCommands = $this->commandManager->getCommandsByIdentifier($commandIdentifier);
$numberOfMatchingCommands = count($matchingCommands);
if ($numberOfMatchingCommands === 0) {
$this->outputLine('No command could be found that matches the command identifier "%s".', [$commandIdentifier]);
} elseif ($numberOfMatchingCommands > 1) {
$this->outputLine('%d commands match the command identifier "%s":', [$numberOfMatchingCommands, $commandIdentifier]);
$this->displayShortHelpForCommands($matchingCommands);
} else {
$this->displayHelpForCommand(array_shift($matchingCommands));
}
}
}