/** * Display help for a command * * The help command displays help for a given command: * ./flow help <commandIdentifier> * * @param string $commandIdentifier Identifier of a command for more details * @return void */ 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".', array($commandIdentifier)); } elseif ($numberOfMatchingCommands > 1) { $this->outputLine('%d commands match the command identifier "%s":', array($numberOfMatchingCommands, $commandIdentifier)); $this->displayShortHelpForCommands($matchingCommands); } else { $this->displayHelpForCommand(array_shift($matchingCommands)); } } }
/** * @test */ public function getCommandsByIdentifierReturnsAllCommandsOfTheSpecifiedPackage() { $mockCommand1 = $this->getMock(\TYPO3\Flow\Cli\Command::class, array(), array(), '', false); $mockCommand1->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('package.key:controller:command')); $mockCommand2 = $this->getMock(\TYPO3\Flow\Cli\Command::class, array(), array(), '', false); $mockCommand2->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('otherpackage.key:controller2:command')); $mockCommand3 = $this->getMock(\TYPO3\Flow\Cli\Command::class, array(), array(), '', false); $mockCommand3->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('packagekey:controller:command')); $mockCommand4 = $this->getMock(\TYPO3\Flow\Cli\Command::class, array(), array(), '', false); $mockCommand4->expects($this->atLeastOnce())->method('getCommandIdentifier')->will($this->returnValue('packagekey:controller:othercommand')); $mockCommands = array($mockCommand1, $mockCommand2, $mockCommand3, $mockCommand4); $this->commandManager->expects($this->once())->method('getAvailableCommands')->will($this->returnValue($mockCommands)); $expectedResult = array($mockCommand3, $mockCommand4); $this->assertSame($expectedResult, $this->commandManager->getCommandsByIdentifier('packagekey')); }