*/
protected function describeInputDefinition(InputDefinition $definition, array $options = [])
{
+ $command_name = null;
+ if (array_key_exists('command', $options)) {
+ $command_name = $options['command']->getName();
+ }
+
$totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
foreach ($definition->getArguments() as $argument) {
$totalWidth = max($totalWidth, strlen($argument->getName()));
}
+
if ($definition->getArguments()) {
$this->writeText($options['translator']->trans('commands.list.messages.arguments'), $options);
$this->writeText("\n");
if ($definition->getOptions()) {
$laterOptions = [];
$this->writeText($options['translator']->trans('commands.list.messages.options'), $options);
+
+ $exitOptionName = 'help';
+ if ($command_name === $exitOptionName) {
+ $exitOptionName = '';
+ }
+
foreach ($definition->getOptions() as $option) {
+ if ($option->getName() === $exitOptionName) {
+ break;
+ }
+
if (strlen($option->getShortcut()) > 1) {
$laterOptions[] = $option;
continue;
$command->getSynopsis(true);
$command->getSynopsis(false);
$command->mergeApplicationDefinition(false);
+
$this->writeText($command->trans('commands.list.messages.usage'), $options);
- foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $usage) {
+ foreach (array_merge([$command->getSynopsis(true)], $command->getAliases(), $command->getUsages()) as $key => $usage) {
+ if ($key > 0) {
+ $this->writeText("\n");
+ }
$this->writeText(' '.$usage, $options);
+ }
+
+ $this->writeText("\n");
+ $definition = $command->getNativeDefinition();
+ if ($definition->getOptions() || $definition->getArguments()) {
+ $this->writeText("\n");
+ $options =
+ array_merge(
+ $options,
+ [ 'command' => $command ]
+ );
+ $this->describeInputDefinition($definition, $options);
$this->writeText("\n");
}
+
if ($examples) {
$this->writeText("\n");
$this->writeText("<comment>Examples:</comment>", $options);
- foreach ($examples as $example) {
+ foreach ($examples as $key => $example) {
$this->writeText("\n");
- $this->writeText(' '.$example['description']);
+ if ($key != 0) {
+ $this->writeText("\n");
+ }
+ $this->writeText(' <info>'.$example['description'].'</info>');
$this->writeText("\n");
$this->writeText(' '.$example['execution']);
- $this->writeText("\n");
}
}
- $this->writeText("\n");
- $definition = $command->getNativeDefinition();
- if ($definition->getOptions() || $definition->getArguments()) {
- $this->writeText("\n");
- $this->describeInputDefinition($definition, $options);
- $this->writeText("\n");
- }
if ($help = $command->getProcessedHelp()) {
$this->writeText("\n");
$this->writeText($command->trans('commands.list.messages.help'), $options);
if ('' != $help = $application->getHelp()) {
$this->writeText("$help\n\n", $options);
}
- $this->writeText($application->trans('commands.list.messages.usage'), $options);
- $this->writeText($application->trans('commands.list.messages.usage_details'), $options);
- $options['application'] = $application;
- $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
- $this->writeText("\n");
- $this->writeText("\n");
+ if (empty($describedNamespace)) {
+ $this->writeText(
+ $application->trans('commands.list.messages.usage'),
+ $options
+ );
+ $this->writeText(
+ $application->trans(
+ 'commands.list.messages.usage-details'
+ ),
+ $options
+ );
+ $options['application'] = $application;
+
+ $this->describeInputDefinition(
+ new InputDefinition(
+ $application->getDefinition()->getOptions()
+ ),
+ $options
+ );
+ $this->writeText("\n");
+ $this->writeText("\n");
+ }
+
$width = $this->getColumnWidth($description->getCommands()) + 4;
if ($describedNamespace) {
$this->writeText(sprintf($application->trans('commands.list.messages.comment'), $describedNamespace), $options);
'about',
'chain',
'check',
+ 'composerize',
'exec',
'help',
'init',
implode(',', $description->getCommand($name)->getAliases())
);
}
+
$spacingWidth = $width - strlen($name.$alias);
+ if ($spacingWidth < 0) {
+ $spacingWidth = 0;
+ }
+
$this->writeText(
sprintf(
' <info>%s</info> <comment>%s</comment> %s%s',
$name,
$alias,
str_repeat(' ', $spacingWidth),
- $description->getCommand($name)->getDescription()
+ $description->getCommand($name)->getDescription(
+ )
),
$options
);