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


PHP Command::setHelp方法代码示例

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


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

示例1: createCommand

 public function createCommand(TaskInfo $taskInfo)
 {
     $task = new Command($taskInfo->getName());
     $task->setDescription($taskInfo->getDescription());
     $task->setHelp($taskInfo->getHelp());
     $args = $taskInfo->getArguments();
     foreach ($args as $name => $val) {
         $description = $taskInfo->getArgumentDescription($name);
         if ($val === TaskInfo::PARAM_IS_REQUIRED) {
             $task->addArgument($name, InputArgument::REQUIRED, $description);
         } elseif (is_array($val)) {
             $task->addArgument($name, InputArgument::IS_ARRAY, $description, $val);
         } else {
             $task->addArgument($name, InputArgument::OPTIONAL, $description, $val);
         }
     }
     $opts = $taskInfo->getOptions();
     foreach ($opts as $name => $val) {
         $description = $taskInfo->getOptionDescription($name);
         $fullName = $name;
         $shortcut = '';
         if (strpos($name, '|')) {
             list($fullName, $shortcut) = explode('|', $name, 2);
         }
         if (is_bool($val)) {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_NONE, $description);
         } else {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_OPTIONAL, $description, $val);
         }
     }
     return $task;
 }
开发者ID:stefanhuber,项目名称:Robo,代码行数:32,代码来源:Application.php

示例2: buildCommand

 /**
  * Build a Symfony Console commands.
  *
  * @param \Yosymfony\Spress\Plugin\CommandPluginInterface $commandPlugin
  *
  * @return \Symfony\Component\Console\Command\Command Symfony Console command.
  */
 protected function buildCommand(CommandPluginInterface $commandPlugin)
 {
     $definition = $commandPlugin->getCommandDefinition();
     $argumentsAndOptions = [];
     $consoleComand = new Command($definition->getName());
     $consoleComand->setDescription($definition->getDescription());
     $consoleComand->setHelp($definition->getHelp());
     foreach ($definition->getArguments() as list($name, $mode, $description, $defaultValue)) {
         $argumentsAndOptions[] = new InputArgument($name, $mode, $description, $defaultValue);
     }
     foreach ($definition->getOptions() as list($name, $shortcut, $mode, $description, $defaultValue)) {
         $argumentsAndOptions[] = new InputOption($name, $shortcut, $mode, $description, $defaultValue);
     }
     $consoleComand->setDefinition($argumentsAndOptions);
     $consoleComand->setCode(function (InputInterface $input, OutputInterface $output) use($commandPlugin) {
         $io = new ConsoleIO($input, $output);
         $arguments = $input->getArguments();
         $options = $input->getOptions();
         $commandPlugin->executeCommand($io, $arguments, $options);
     });
     return $consoleComand;
 }
开发者ID:jjk-jacky,项目名称:Spress,代码行数:29,代码来源:ConsoleCommandBuilder.php

示例3: setHelp

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

示例4: createCommand

 /**
  * @param $className
  * @param TaskInfo $taskInfo
  * @return Command
  */
 protected function createCommand($className, TaskInfo $taskInfo)
 {
     if ($className === strtolower(Tg::TGCLASS)) {
         $name = $taskInfo->getName();
     } else {
         $camel = preg_replace("/:/", '-', $taskInfo->getName());
         $name = $className . ':' . $camel;
     }
     $task = new Command($name);
     $task->setDescription($taskInfo->getDescription());
     $task->setHelp($taskInfo->getHelp());
     $args = $taskInfo->getArguments();
     foreach ($args as $name => $val) {
         $description = $taskInfo->getArgumentDescription($name);
         if ($val === TaskInfo::PARAM_IS_REQUIRED) {
             $task->addArgument($name, InputArgument::REQUIRED, $description);
         } elseif (is_array($val)) {
             $task->addArgument($name, InputArgument::IS_ARRAY, $description, $val);
         } else {
             $task->addArgument($name, InputArgument::OPTIONAL, $description, $val);
         }
     }
     $opts = $taskInfo->getOptions();
     foreach ($opts as $name => $val) {
         $description = $taskInfo->getOptionDescription($name);
         $fullName = $name;
         $shortcut = '';
         if (strpos($name, '|')) {
             list($fullName, $shortcut) = explode('|', $name, 2);
         }
         if (is_bool($val)) {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_NONE, $description);
         } else {
             $task->addOption($fullName, $shortcut, InputOption::VALUE_OPTIONAL, $description, $val);
         }
     }
     return $task;
 }
开发者ID:twhiston,项目名称:tg,代码行数:43,代码来源:CommandLoader.php

示例5: setHelp

 public function setHelp($help)
 {
     $this->rawHelp = $help;
     $help = preg_replace('/```\\n(.*?)\\n```/mis', '<info>$1</info>', $help);
     $help = preg_replace('/(\\n|^)#+ (.*)/', '$1<question>$2</question>', $help);
     $help = preg_replace('/`([^`]*?)`/', '<comment>$1</comment>', $help);
     $help = preg_replace('/\\*\\*(.*?)\\*\\*/', '<comment>$1</comment>', $help);
     return parent::setHelp($help);
 }
开发者ID:popstas,项目名称:transmission-cli,代码行数:9,代码来源:Command.php

示例6: setHelp

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

示例7: addCommand

 /**
  * Registers a command.
  * 
  * @param string $name Name of the command.
  * @param string $commandClass Class name of the command.
  */
 public function addCommand($name, $commandClass)
 {
     // must extend AbstractCommand
     $abstractCommandClass = AbstractCommand::class;
     if (!Debugger::isExtending($commandClass, $abstractCommandClass)) {
         throw new InvalidCommandException('Command "' . $commandClass . '" must extend "' . $abstractCommandClass . '".');
     }
     // name cannot be empty
     $name = trim($name);
     if (empty($name)) {
         throw new InvalidArgumentException('Command name cannot be empty for "' . $commandClass . '"!');
     }
     // configure the command
     $console = $this;
     $consoleCommand = new ConsoleCommand($name);
     $consoleCommand->setDescription($commandClass::getDescription());
     $consoleCommand->setHelp($commandClass::getHelp());
     $consoleCommand->setCode(function (InputInterface $input, OutputInterface $output) use($console, $name) {
         $console->exec($name, $input, $output);
     });
     // read some meta info about the command
     $commandReflection = new \ReflectionClass($commandClass);
     $arguments = array();
     $argumentsDescriptions = $commandClass::getArguments();
     try {
         $methodReflection = $commandReflection->getMethod('execute');
         if (!$methodReflection->isPublic() || $methodReflection->isStatic()) {
             throw new InvalidCommandException('The "execute()" method for ommand "' . $commandClass . '" must be public and non-static.');
         }
         // get the execute() method's arguments so we can translate them to CLI arguments
         $parametersReflection = $methodReflection->getParameters();
         foreach ($parametersReflection as $param) {
             $optional = $param->isDefaultValueAvailable();
             $paramName = $param->getName();
             $arguments[] = array('name' => $paramName, 'optional' => $optional, 'default' => $optional ? $param->getDefaultValue() : null, 'description' => isset($argumentsDescriptions[$paramName]) ? $argumentsDescriptions[$paramName] : '');
         }
     } catch (\ReflectionException $e) {
         throw new InvalidCommandException('Command "' . $commandClass . '" must implement public function "execute()"!');
     }
     foreach ($arguments as $argument) {
         $consoleCommand->addArgument($argument['name'], $argument['optional'] ? InputArgument::OPTIONAL : InputArgument::REQUIRED, $argument['description'], $argument['default']);
     }
     // also register command's options
     $options = $commandClass::getOptions();
     foreach ($options as $option => $optionInfo) {
         $value = isset($optionInfo['required']) && $optionInfo['required'] ? InputOption::VALUE_REQUIRED : (!isset($optionInfo['default']) || empty($optionInfo['default']) || $optionInfo['default'] === null ? InputOption::VALUE_NONE : InputOption::VALUE_OPTIONAL);
         $consoleCommand->addOption($option, isset($optionInfo['shortcut']) ? $optionInfo['shortcut'] : null, $value, isset($optionInfo['description']) ? $optionInfo['description'] : '', $value === InputOption::VALUE_REQUIRED || $value === InputOption::VALUE_NONE ? null : (isset($optionInfo['default']) ? $optionInfo['default'] : null));
     }
     // register the command
     $this->commands[$name] = array('name' => $name, 'class' => $commandClass, 'command' => $consoleCommand, 'arguments' => $arguments, 'options' => $options);
     $this->consoleApplication->add($consoleCommand);
 }
开发者ID:splot,项目名称:framework,代码行数:58,代码来源:Console.php

示例8: setHelp

 /**
  * Define uma ajuda par ao comando
  * @param string $help
  * @return BaseCommand
  */
 public function setHelp($help)
 {
     parent::setHelp($help);
     return $this;
 }
开发者ID:primephp,项目名称:framework,代码行数:10,代码来源:BaseCommand.php


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