Exemplo n.º 1
0
 /**
  * 描述输入
  * @param InputDefinition $definition
  * @param array           $options
  * @return string|mixed
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = [])
 {
     $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
     foreach ($definition->getArguments() as $argument) {
         $totalWidth = max($totalWidth, strlen($argument->getName()));
     }
     if ($definition->getArguments()) {
         $this->writeText('<comment>Arguments:</comment>', $options);
         $this->writeText("\n");
         foreach ($definition->getArguments() as $argument) {
             $this->describeInputArgument($argument, array_merge($options, ['total_width' => $totalWidth]));
             $this->writeText("\n");
         }
     }
     if ($definition->getArguments() && $definition->getOptions()) {
         $this->writeText("\n");
     }
     if ($definition->getOptions()) {
         $laterOptions = [];
         $this->writeText('<comment>Options:</comment>', $options);
         foreach ($definition->getOptions() as $option) {
             if (strlen($option->getShortcut()) > 1) {
                 $laterOptions[] = $option;
                 continue;
             }
             $this->writeText("\n");
             $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth]));
         }
         foreach ($laterOptions as $option) {
             $this->writeText("\n");
             $this->describeInputOption($option, array_merge($options, ['total_width' => $totalWidth]));
         }
     }
 }
Exemplo n.º 2
0
 /**
  * 是否有某个选项
  * @param string $name 选项名
  * @return bool
  */
 public function hasOption($name)
 {
     return $this->definition->hasOption($name);
 }
Exemplo n.º 3
0
 /**
  * 是否有某个选项
  * @param string $name 选项名
  * @return bool
  */
 public function hasOption($name)
 {
     return $this->definition->hasOption($name) && isset($this->options[$name]);
 }