Example #1
0
 /**
  * 描述参数
  * @param InputArgument $argument
  * @param array         $options
  * @return string|mixed
  */
 protected function describeInputArgument(InputArgument $argument, array $options = [])
 {
     if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {
         $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
     } else {
         $default = '';
     }
     $totalWidth = isset($options['total_width']) ? $options['total_width'] : strlen($argument->getName());
     $spacingWidth = $totalWidth - strlen($argument->getName()) + 2;
     $this->writeText(sprintf("  <info>%s</info>%s%s%s", $argument->getName(), str_repeat(' ', $spacingWidth), preg_replace('/\\s*\\R\\s*/', PHP_EOL . str_repeat(' ', $totalWidth + 17), $argument->getDescription()), $default), $options);
 }