当前位置: 首页>>代码示例>>PHP>>正文


PHP Command::getSynopsis方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Command\Command::getSynopsis方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::getSynopsis方法的具体用法?PHP Command::getSynopsis怎么用?PHP Command::getSynopsis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Command\Command的用法示例。


在下文中一共展示了Command::getSynopsis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: describeCommand

 /**
  * @inheritdoc
  */
 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $this->writeText("<comment>Command:</comment> " . $command->getName(), $options);
     if ($aliases = $command->getAliases()) {
         $this->writeText("\n");
         $this->writeText('<comment>Aliases:</comment> ' . implode(', ', $aliases), $options);
     }
     if ($description = $command->getDescription()) {
         $this->writeText("\n");
         $this->writeText("<comment>Description:</comment> {$description}", $options);
     }
     $this->writeText("\n\n");
     $this->writeText('<comment>Usage:</comment>', $options);
     $this->writeText("\n");
     $this->writeText(' ' . $command->getSynopsis(), $options);
     $this->writeText("\n");
     if ($definition = $command->getNativeDefinition()) {
         $this->writeText("\n");
         $this->describeInputDefinition($definition, $options);
     }
     if ($help = $command->getProcessedHelp()) {
         $this->writeText("\n");
         $this->writeText('<comment>Help:</comment>', $options);
         $this->writeText("\n");
         $this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
         $this->writeText("\n");
     }
 }
开发者ID:pjcdawkins,项目名称:platformsh-cli,代码行数:33,代码来源:CustomTextDescriptor.php

示例2: describeCommand

 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis(true);
     $command->getSynopsis(false);
     $command->mergeApplicationDefinition(false);
     $this->writeText('<comment>Usage:</comment>', $options);
     foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
         $this->writeText("\n");
         $this->writeText('  ' . $usage, $options);
     }
     $this->writeText("\n");
     $definition = $command->getNativeDefinition();
     if ($definition->getOptions() || $definition->getArguments()) {
         $this->writeText("\n");
         $this->describeInputDefinition($definition, $options);
         $this->writeText("\n");
     }
     if ($help = $command->getProcessedHelp()) {
         $this->writeText("\n");
         $this->writeText('<comment>Help:</comment>', $options);
         $this->writeText("\n");
         $this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
         $this->writeText("\n");
     }
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:25,代码来源:TextDescriptor.php

示例3: describeCommand

 /**
  * @inheritdoc
  */
 protected function describeCommand(Command $command, array $options = [])
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $this->write($command->getName() . "\n" . str_repeat('-', strlen($command->getName())) . "\n");
     if ($description = $command->getDescription()) {
         $this->write("{$description}\n\n");
     }
     $aliases = $command instanceof CommandBase ? $command->getVisibleAliases() : $command->getAliases();
     if ($aliases) {
         $this->write('Aliases: ' . '`' . implode('`, `', $aliases) . '`' . "\n\n");
     }
     $executableName = 'platform';
     $this->write("## Usage:\n\n```\n{$executableName} " . $command->getSynopsis() . "\n```\n\n");
     if ($help = $command->getProcessedHelp()) {
         $this->write($help);
         $this->write("\n\n");
     }
     if ($command->getNativeDefinition()) {
         $this->describeInputDefinition($command->getNativeDefinition());
         $this->write("\n\n");
     }
     if ($command instanceof CommandBase && ($examples = $command->getExamples())) {
         $this->write('## Examples');
         $this->write("\n");
         $name = $command->getName();
         foreach ($examples as $arguments => $description) {
             $this->write("\n* {$description}:  \n  ```\n  platform {$name} {$arguments}\n  ```\n");
         }
         $this->write("\n");
     }
 }
开发者ID:drewmelck,项目名称:platformsh-cli,代码行数:35,代码来源:CustomMarkdownDescriptor.php

示例4: updateCommandDefinition

 private function updateCommandDefinition(Command $command, OutputInterface $output)
 {
     $eventDispatcher = $this->getApplication()->getDispatcher();
     $input = new ArrayInput(['command' => $command->getName()]);
     $event = new ConsoleCommandEvent($command, $input, $output);
     $eventDispatcher->dispatch(GushEvents::DECORATE_DEFINITION, $event);
     $command->getSynopsis(true);
     $command->getSynopsis(false);
     $command->mergeApplicationDefinition();
     try {
         $input->bind($command->getDefinition());
     } catch (\Exception $e) {
         $output->writeln('<error>Something went wrong: </error>' . $e->getMessage());
         return;
     }
     $eventDispatcher->dispatch(GushEvents::INITIALIZE, $event);
     // The options were set on the input but now we need to set them on the Command definition
     if ($options = $input->getOptions()) {
         foreach ($options as $name => $value) {
             $option = $command->getDefinition()->getOption($name);
             if ($option->acceptValue()) {
                 $option->setDefault($value);
             }
         }
     }
 }
开发者ID:mistymagich,项目名称:gush,代码行数:26,代码来源:HelpCommand.php

示例5: describeCommand

 /**
  * {@inheritdoc}
  */
 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $markdown = $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()) {
         $markdown .= "\n\n" . $help;
     }
     if ($definitionMarkdown = $this->describeInputDefinition($command->getNativeDefinition())) {
         $markdown .= "\n\n" . $definitionMarkdown;
     }
     return $markdown;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:16,代码来源:MarkdownDescriptor.php

示例6: describeCommand

 /**
  * {@inheritdoc}
  */
 protected function describeCommand(Command $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:' . "\n\n" . array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
         return $carry .= '  * `' . $usage . '`' . "\n";
     }));
     if ($help = $command->getProcessedHelp()) {
         $this->write("\n");
         $this->write($help);
     }
     if ($command->getNativeDefinition()) {
         $this->write("\n\n");
         $this->describeInputDefinition($command->getNativeDefinition());
     }
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:19,代码来源:MarkdownDescriptor.php

示例7: renderException

 /**
  * {@inheritdoc}
  */
 public function renderException(\Exception $e, OutputInterface $output)
 {
     $output->writeln('', OutputInterface::VERBOSITY_QUIET);
     do {
         $exceptionName = get_class($e);
         if (($pos = strrpos($exceptionName, '\\')) !== false) {
             $exceptionName = substr($exceptionName, $pos + 1);
         }
         $title = sprintf('  [%s]  ', $exceptionName);
         $len = strlen($title);
         $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
         // HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
         if (defined('HHVM_VERSION') && $width > 1 << 31) {
             $width = 1 << 31;
         }
         $formatter = $output->getFormatter();
         $lines = array();
         foreach (preg_split('/\\r?\\n/', $e->getMessage()) as $line) {
             foreach (str_split($line, $width - 4) as $chunk) {
                 // pre-format lines to get the right string length
                 $lineLength = strlen(preg_replace('/\\[[^m]*m/', '', $formatter->format($chunk))) + 4;
                 $lines[] = array($chunk, $lineLength);
                 $len = max($lineLength, $len);
             }
         }
         $messages = array();
         $messages[] = $emptyLine = $formatter->format(sprintf('<error>%s</error>', str_repeat(' ', $len)));
         $messages[] = $formatter->format(sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - strlen($title)))));
         foreach ($lines as $line) {
             $messages[] = $formatter->format(sprintf('<error>  %s  %s</error>', $line[0], str_repeat(' ', $len - $line[1])));
         }
         $messages[] = $emptyLine;
         $messages[] = '';
         $output->writeln($messages, OutputInterface::OUTPUT_RAW | OutputInterface::VERBOSITY_QUIET);
         if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
             $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
             // exception related properties
             $trace = $e->getTrace();
             array_unshift($trace, array('function' => '', 'file' => $e->getFile() !== null ? $e->getFile() : 'n/a', 'line' => $e->getLine() !== null ? $e->getLine() : 'n/a', 'args' => array()));
             for ($i = 0, $count = count($trace); $i < $count; ++$i) {
                 $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
                 $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
                 $function = $trace[$i]['function'];
                 $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
                 $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
                 $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET);
             }
             $output->writeln('', OutputInterface::VERBOSITY_QUIET);
         }
     } while ($e = $e->getPrevious());
     if (null !== $this->currentCommand && $this->currentCommand->getName() !== 'welcome') {
         $output->writeln(sprintf('Usage: <info>%s</info>', $this->currentCommand->getSynopsis()), OutputInterface::VERBOSITY_QUIET);
         $output->writeln('', OutputInterface::VERBOSITY_QUIET);
         $output->writeln(sprintf('For more information, type: <info>%s help %s</info>', $this->cliConfig->get('application.executable'), $this->currentCommand->getName()), OutputInterface::VERBOSITY_QUIET);
         $output->writeln('', OutputInterface::VERBOSITY_QUIET);
     }
 }
开发者ID:commerceguys,项目名称:platform-cli,代码行数:60,代码来源:Application.php

示例8: getCommandDocument

 /**
  * @param Command $command
  *
  * @return \DOMDocument
  */
 public function getCommandDocument(Command $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($usagesXML = $dom->createElement('usages'));
     foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
         $usagesXML->appendChild($dom->createElement('usage', $usage));
     }
     $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())));
     $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
     $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
     return $dom;
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:25,代码来源:XmlDescriptor.php

示例9: describeCommand

 /**
  * @inheritdoc
  */
 protected function describeCommand(Command $command, array $options = [])
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     $this->writeText("<comment>Command:</comment> " . $command->getName(), $options);
     $aliases = $command instanceof CommandBase ? $command->getVisibleAliases() : $command->getAliases();
     if ($aliases) {
         $this->writeText("\n");
         $this->writeText('<comment>Aliases:</comment> ' . implode(', ', $aliases), $options);
     }
     if ($description = $command->getDescription()) {
         $this->writeText("\n");
         $this->writeText("<comment>Description:</comment> {$description}", $options);
     }
     $this->writeText("\n\n");
     $this->writeText('<comment>Usage:</comment>', $options);
     $this->writeText("\n");
     $executableName = 'platform';
     $this->writeText(' ' . $executableName . ' ' . $command->getSynopsis(), $options);
     $this->writeText("\n");
     if ($definition = $command->getNativeDefinition()) {
         $this->writeText("\n");
         $this->describeInputDefinition($definition, $options);
         $this->writeText("\n");
     }
     if ($help = $command->getProcessedHelp()) {
         $this->writeText("\n");
         $this->writeText('<comment>Help:</comment>', $options);
         $this->writeText("\n");
         $this->writeText(' ' . str_replace("\n", "\n ", $help), $options);
         $this->writeText("\n");
     }
     if ($command instanceof CommandBase && ($examples = $command->getExamples())) {
         $this->writeText("\n");
         $this->writeText('<comment>Examples:</comment>', $options);
         $name = $command->getName();
         foreach ($examples as $arguments => $description) {
             $this->writeText("\n {$description}:\n   <info>platform {$name} {$arguments}</info>\n");
         }
     }
 }
开发者ID:drewmelck,项目名称:platformsh-cli,代码行数:44,代码来源:CustomTextDescriptor.php

示例10: describeCommand

 /**
  * {@inheritdoc}
  */
 protected function describeCommand(Command $command, array $options = array())
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     return $this->output(array('name' => $command->getName(), 'usage' => $command->getSynopsis(), 'description' => $command->getDescription(), 'help' => $command->getProcessedHelp(), 'aliases' => $command->getAliases(), 'definition' => $this->describeInputDefinition($command->getNativeDefinition(), array('as_array' => true))), $options);
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:9,代码来源:JsonDescriptor.php

示例11: getCommandData

 /**
  * @param Command $command
  *
  * @return array
  */
 private function getCommandData(Command $command)
 {
     $command->getSynopsis();
     $command->mergeApplicationDefinition(false);
     return array('name' => $command->getName(), 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()), 'description' => $command->getDescription(), 'help' => $command->getProcessedHelp(), 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()));
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:11,代码来源:JsonDescriptor.php

示例12: getSynopsis

 /**
  * {@inheritdoc}
  */
 public function getSynopsis($short = false)
 {
     return $this->decoratedCommand->getSynopsis($short);
 }
开发者ID:frankdejonge,项目名称:locked-console-command,代码行数:7,代码来源:LockedCommandDecorator.php

示例13: getSynopsis

 public function getSynopsis()
 {
     return parent::getSynopsis() . "\n\n<comment>Description:</comment>\n " . $this->getDescription();
 }
开发者ID:qonitaqoni,项目名称:qonimax,代码行数:4,代码来源:TokenizeCommand.php

示例14: getSynopsis

 public function getSynopsis($short = false)
 {
     return $this->innerCommand->getSynopsis($short);
 }
开发者ID:lolautruche,项目名称:ezsh,代码行数:4,代码来源:WrappedCommand.php

示例15: getSynopsis

 /**
  * Merge in job definition
  *
  * @param bool $short Whether to return short synopsis
  *
  * @return string
  */
 public function getSynopsis($short = false)
 {
     if (!$this->jobDefinitionMerged) {
         $definition = $this->getJob()->getDefinition();
         $this->getDefinition()->addOptions($definition->getOptions());
         $this->getDefinition()->addArguments($definition->getArguments());
         $this->jobDefinitionMerged = true;
     }
     return preg_replace('/^generic:([^:]+):([^ ]+)/', '--$1=$2', parent::getSynopsis($short));
 }
开发者ID:netresearch,项目名称:kite,代码行数:17,代码来源:JobCommand.php


注:本文中的Symfony\Component\Console\Command\Command::getSynopsis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。