Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     $nameWidth = 0;
     foreach ($definition->getOptions() as $option) {
         $nameLength = strlen($option->getName()) + 2;
         if ($option->getShortcut()) {
             $nameLength += strlen($option->getShortcut()) + 3;
         }
         $nameWidth = max($nameWidth, $nameLength);
     }
     foreach ($definition->getArguments() as $argument) {
         $nameWidth = max($nameWidth, strlen($argument->getName()));
     }
     ++$nameWidth;
     if ($definition->getArguments()) {
         $this->writeText('<comment>Arguments:</comment>', $options);
         $this->writeText("\n");
         foreach ($definition->getArguments() as $argument) {
             $this->describeInputArgument($argument, array_merge($options, array('name_width' => $nameWidth)));
             $this->writeText("\n");
         }
     }
     if ($definition->getArguments() && $definition->getOptions()) {
         $this->writeText("\n");
     }
     if ($definition->getOptions()) {
         $this->writeText('<comment>Options:</comment>', $options);
         $this->writeText("\n");
         foreach ($definition->getOptions() as $option) {
             $this->describeInputOption($option, array_merge($options, array('name_width' => $nameWidth)));
             $this->writeText("\n");
         }
     }
 }
Beispiel #2
0
 /**
  * {@inheritdoc}
  */
 protected function describeInputDefinition(InputDefinition $definition, array $options = array())
 {
     if ($showArguments = count($definition->getArguments()) > 0) {
         $this->write('### Arguments:');
         foreach ($definition->getArguments() as $argument) {
             $this->write("\n\n");
             $this->write($this->describeInputArgument($argument));
         }
     }
     if (count($definition->getOptions()) > 0) {
         if ($showArguments) {
             $this->write("\n\n");
         }
         $this->write('### Options:');
         foreach ($definition->getOptions() as $option) {
             $this->write("\n\n");
             $this->write($this->describeInputOption($option));
         }
     }
 }
Beispiel #3
0
 /**
  * @param InputDefinition $definition
  *
  * @return \DOMDocument
  */
 public function getInputDefinitionDocument(InputDefinition $definition)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($definitionXML = $dom->createElement('definition'));
     $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
     foreach ($definition->getArguments() as $argument) {
         $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
     }
     $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
     foreach ($definition->getOptions() as $option) {
         $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
     }
     return $dom;
 }
Beispiel #4
0
 public function testAddOption()
 {
     $this->initializeOptions();
     $definition = new InputDefinition();
     $definition->addOption($this->foo);
     $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->addOption() adds a InputOption object');
     $definition->addOption($this->bar);
     $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '->addOption() adds a InputOption object');
 }
Beispiel #5
0
 /**
  * @param InputDefinition $definition
  *
  * @return array
  */
 private function getInputDefinitionData(InputDefinition $definition)
 {
     $inputArguments = array();
     foreach ($definition->getArguments() as $name => $argument) {
         $inputArguments[$name] = $this->getInputArgumentData($argument);
     }
     $inputOptions = array();
     foreach ($definition->getOptions() as $name => $option) {
         $inputOptions[$name] = $this->getInputOptionData($option);
     }
     return array('arguments' => $inputArguments, 'options' => $inputOptions);
 }