53 $this->
outputLine(
'usage: ' . $this->request->getCallingScript() .
' <command identifier>');
55 $this->
outputLine(
'See \'' . $this->request->getCallingScript() .
' help\' for a list of all available commands.');
69 if ($commandIdentifier ===
null) {
73 $command = $this->commandManager->getCommandByIdentifier($commandIdentifier);
89 $this->
outputLine(
'usage: ' . $this->request->getCallingScript() .
' <command identifier>');
91 $this->
outputLine(
'The following commands are currently available:');
92 foreach ($this->commandsByExtensionsAndControllers as $extensionKey => $commandControllers) {
94 $this->
outputLine(
'EXTENSION "%s":', [strtoupper($extensionKey)]);
96 foreach ($commandControllers as $commands) {
97 foreach ($commands as $command) {
98 $description = wordwrap($command->getShortDescription(), $this->output->getMaximumLineLength() - 43, PHP_EOL . str_repeat(
' ', 43),
true);
99 $shortCommandIdentifier = $this->commandManager->getShortestIdentifierForCommand($command);
100 $this->
outputLine(
'%-2s%-40s %s', [
' ', $shortCommandIdentifier, $description]);
105 $this->
outputLine(
'See \'' . $this->request->getCallingScript() .
' help <command identifier>\' for more information about a specific command.');
117 $this->
outputLine($command->getShortDescription());
120 $this->
outputLine(
'%-2s%s', [
' ', $command->getCommandIdentifier()]);
121 $commandArgumentDefinitions = $command->getArgumentDefinitions();
124 foreach ($commandArgumentDefinitions as $commandArgumentDefinition) {
125 if (!$commandArgumentDefinition->isRequired()) {
128 $usage .= sprintf(
' <%s>', strtolower(preg_replace(
'/([A-Z])/',
' $1', $commandArgumentDefinition->getName())));
131 $usage = $this->request->getCallingScript() .
' ' . $this->commandManager->getShortestIdentifierForCommand($command) . ($hasOptions ?
' [<options>]' :
'') . $usage;
135 $argumentDescriptions = [];
136 $optionDescriptions = [];
137 if ($command->hasArguments()) {
138 foreach ($commandArgumentDefinitions as $commandArgumentDefinition) {
139 $argumentDescription = $commandArgumentDefinition->getDescription();
140 $argumentDescription = wordwrap($argumentDescription, $this->
output->getMaximumLineLength() - 23, PHP_EOL . str_repeat(
' ', 23),
true);
141 if ($commandArgumentDefinition->isRequired()) {
142 $argumentDescriptions[] = vsprintf(
' %-20s %s', [$commandArgumentDefinition->getDashedName(), $argumentDescription]);
144 $optionDescriptions[] = vsprintf(
' %-20s %s', [$commandArgumentDefinition->getDashedName(), $argumentDescription]);
148 if (!empty($argumentDescriptions)) {
151 foreach ($argumentDescriptions as $argumentDescription) {
155 if (!empty($optionDescriptions)) {
158 foreach ($optionDescriptions as $optionDescription) {
162 if ($command->getDescription() !==
'') {
165 $descriptionLines = explode(LF, $command->getDescription());
166 foreach ($descriptionLines as $descriptionLine) {
167 $this->
outputLine(
'%-2s%s', [
' ', $descriptionLine]);
170 $relatedCommandIdentifiers = $command->getRelatedCommandIdentifiers();
171 if ($relatedCommandIdentifiers !== []) {
174 foreach ($relatedCommandIdentifiers as $commandIdentifier) {
175 $command = $this->commandManager->getCommandByIdentifier($commandIdentifier);
176 $this->
outputLine(
'%-2s%s (%s)', [
' ', $commandIdentifier, $command->getShortDescription()]);
192 $this->
outputLine(
'Please specify the complete command identifier. Matched commands:');
193 foreach ($exception->getMatchingCommands() as $matchingCommand) {
194 $this->
outputLine(
' %s', [$matchingCommand->getCommandIdentifier()]);
198 $this->
outputLine(
'Enter "' . $this->request->getCallingScript() .
' help" for an overview of all available commands');
199 $this->
outputLine(
'or "' . $this->request->getCallingScript() .
' help <command identifier>" for a detailed description of the corresponding command.');
208 $availableCommands = $this->commandManager->getAvailableCommands();
209 foreach ($availableCommands as $command) {
210 if ($command->isInternal()) {
213 $commandIdentifier = $command->getCommandIdentifier();
214 $extensionKey = strstr($commandIdentifier,
':',
true);
215 $commandControllerClassName = $command->getControllerClassName();
216 $commandName = $command->getControllerCommandName();
217 $this->commandsByExtensionsAndControllers[$extensionKey][$commandControllerClassName][$commandName] = $command;