Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TextDescriptor.php

function TextDescriptor::describeInputOption

Overrides Descriptor::describeInputOption

1 call to TextDescriptor::describeInputOption()
TextDescriptor::describeInputDefinition in vendor/symfony/console/Descriptor/TextDescriptor.php
Describes an InputDefinition instance.

File

vendor/symfony/console/Descriptor/TextDescriptor.php, line 51

Class

TextDescriptor
Text descriptor.

Namespace

Symfony\Component\Console\Descriptor

Code

protected function describeInputOption(InputOption $option, array $options = []) : void {
    if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
        $default = \sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
    }
    else {
        $default = '';
    }
    $value = '';
    if ($option->acceptValue()) {
        $value = '=' . strtoupper($option->getName());
        if ($option->isValueOptional()) {
            $value = '[' . $value . ']';
        }
    }
    $totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([
        $option,
    ]);
    $synopsis = \sprintf('%s%s', $option->getShortcut() ? \sprintf('-%s, ', $option->getShortcut()) : '    ', \sprintf($option->isNegatable() ? '--%1$s|--no-%1$s' : '--%1$s%2$s', $option->getName(), $value));
    $spacingWidth = $totalWidth - Helper::width($synopsis);
    $this->writeText(\sprintf('  <info>%s</info>  %s%s%s%s', $synopsis, str_repeat(' ', $spacingWidth), preg_replace('/\\s*[\\r\\n]\\s*/', "\n" . str_repeat(' ', $totalWidth + 4), $option->getDescription()), $default, $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''), $options);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal