コード例 #1
0
ファイル: XmlDescriptor.php プロジェクト: Danack/Console
 /**
  * @param AbstractCommand $command
  *
  * @return \DOMDocument
  */
 public function getCommandDocument(AbstractCommand $command)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->appendChild($commandXML = $dom->createElement('command'));
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $commandXML->setAttribute('id', $command->getName());
     $commandXML->setAttribute('name', $command->getName());
     $commandXML->appendChild($usageXML = $dom->createElement('usage'));
     $usageXML->appendChild($dom->createTextNode(sprintf($command->getSynopsis(), '')));
     $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
     $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
     $commandXML->appendChild($helpXML = $dom->createElement('help'));
     $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
     $commandXML->appendChild($aliasesXML = $dom->createElement('aliases'));
     foreach ($command->getAliases() as $alias) {
         $aliasesXML->appendChild($aliasXML = $dom->createElement('alias'));
         $aliasXML->appendChild($dom->createTextNode($alias));
     }
     $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
     $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
     return $dom;
 }
コード例 #2
0
ファイル: Application.php プロジェクト: Danack/Console
 /**
  * @param AbstractCommand $command
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return array An array of [$callable, $parameters] that should be called for the command
  * @throws \Exception
  */
 protected function doRunCommand(AbstractCommand $command, InputInterface $input, OutputInterface $output)
 {
     foreach ($command->getHelperSet() as $helper) {
         if ($helper instanceof InputAwareInterface) {
             $helper->setInput($input);
         }
     }
     return $command->run($input, $output);
 }
コード例 #3
0
ファイル: Command.php プロジェクト: Danack/Console
 function __construct($name, $callable)
 {
     parent::__construct($name);
     $this->callable = $callable;
 }
コード例 #4
0
ファイル: JsonDescriptor.php プロジェクト: Danack/Console
 /**
  * @param AbstractCommand $command
  *
  * @return array
  */
 private function getCommandData(AbstractCommand $command)
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     return array('name' => $command->getName(), 'usage' => $command->getSynopsis(), 'description' => $command->getDescription(), 'help' => $command->getProcessedHelp(), 'aliases' => $command->getAliases(), 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()));
 }
コード例 #5
0
ファイル: MarkdownDescriptor.php プロジェクト: Danack/Console
 /**
  * {@inheritdoc}
  */
 protected function describeCommand(AbstractCommand $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $this->write($command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n\n" . '* Description: ' . ($command->getDescription() ?: '<none>') . "\n" . '* Usage: `' . $command->getSynopsis() . '`' . "\n" . '* Aliases: ' . (count($command->getAliases()) ? '`' . implode('`, `', $command->getAliases()) . '`' : '<none>'));
     if ($help = $command->getProcessedHelp()) {
         $this->write("\n\n");
         $this->write($help);
     }
     if ($definition = $command->getNativeDefinition()) {
         $this->write("\n\n");
         $this->describeInputDefinition($command->getNativeDefinition());
     }
 }
コード例 #6
0
ファイル: TextDescriptor.php プロジェクト: Danack/Console
 /**
  * {@inheritdoc}
  */
 protected function describeCommand(AbstractCommand $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $this->writeText('<comment>Usage:</comment>', $options);
     $this->writeText("\n");
     $this->writeText(' ' . $command->getSynopsis(), $options);
     $this->writeText("\n");
     if (count($command->getAliases()) > 0) {
         $this->writeText("\n");
         $this->writeText('<comment>Aliases:</comment> <info>' . implode(', ', $command->getAliases()) . '</info>', $options);
     }
     if ($definition = $command->getNativeDefinition()) {
         $this->writeText("\n");
         $this->describeInputDefinition($definition, $options);
     }
     $this->writeText("\n");
     if ($help = $command->getProcessedHelp()) {
         $this->writeText('<comment>Help:</comment>', $options);
         $this->writeText("\n");
         $this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
         $this->writeText("\n");
     }
 }