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


PHP Command::addArgument方法代码示例

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


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

示例1: configure

 /**
  * {@inheritdoc}
  */
 public function configure(Command $command)
 {
     $locatorsExamples = implode(PHP_EOL, array_map(function ($locator) {
         return '- ' . $locator;
     }, $this->specificationFinder->getExampleLocators()));
     $command->addArgument('paths', InputArgument::OPTIONAL, 'Optional path(s) to execute. Could be:' . PHP_EOL . $locatorsExamples)->addOption('--dry-run', null, InputOption::VALUE_NONE, 'Invokes formatters without executing the tests and hooks.');
 }
开发者ID:OverByThere,项目名称:Behat,代码行数:10,代码来源:ExerciseController.php

示例2: 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

示例3: configure

 public static function configure(Command $command)
 {
     $command->addArgument('path', InputArgument::OPTIONAL, 'Path to benchmark(s)');
     $command->addOption('filter', array(), InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore all benchmarks not matching command filter (can be a regex)');
     $command->addOption('group', array(), InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Group to run (can be specified multiple times)');
     $command->addOption('parameters', null, InputOption::VALUE_REQUIRED, 'Override parameters to use in (all) benchmarks');
     $command->addOption('revs', null, InputOption::VALUE_REQUIRED, 'Override number of revs (revolutions) on (all) benchmarks');
     $command->addOption('progress', 'l', InputOption::VALUE_REQUIRED, 'Progress logger to use, one of <comment>dots</comment>, <comment>classdots</comment>');
     // command option is parsed before the container is compiled.
     $command->addOption('bootstrap', 'b', InputOption::VALUE_REQUIRED, 'Set or override the bootstrap file.');
     $command->addOption('group', array(), InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Group to run (can be specified multiple times)');
     $command->addOption('executor', array(), InputOption::VALUE_REQUIRED, 'Executor to use', 'microtime');
 }
开发者ID:Remo,项目名称:phpbench,代码行数:13,代码来源:RunnerHandler.php

示例4: configure

 public static function configure(Command $command)
 {
     $command->addArgument('path', InputArgument::OPTIONAL, 'Path to benchmark(s)');
     $command->addOption('filter', [], InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore all benchmarks not matching command filter (can be a regex)');
     $command->addOption('group', [], InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Group to run (can be specified multiple times)');
     $command->addOption('parameters', null, InputOption::VALUE_REQUIRED, 'Override parameters to use in (all) benchmarks');
     $command->addOption('revs', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Override number of revs (revolutions) on (all) benchmarks');
     $command->addOption('progress', 'l', InputOption::VALUE_REQUIRED, 'Progress logger to use, one of <comment>dots</comment>, <comment>classdots</comment>');
     // command option is parsed before the container is compiled.
     $command->addOption('bootstrap', 'b', InputOption::VALUE_REQUIRED, 'Set or override the bootstrap file.');
     $command->addOption('group', [], InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Group to run (can be specified multiple times)');
     $command->addOption('executor', [], InputOption::VALUE_REQUIRED, 'Executor to use', 'microtime');
     $command->addOption('stop-on-error', [], InputOption::VALUE_NONE, 'Stop on the first error encountered.');
     // Launcher options (processed in PhpBench.php before the container is initialized).
     $command->addOption('php-binary', null, InputOption::VALUE_REQUIRED, 'Alternative PHP binary to use');
     $command->addOption('php-config', null, InputOption::VALUE_REQUIRED, 'JSON-like object of PHP INI settings');
     $command->addOption('php-wrapper', null, InputOption::VALUE_REQUIRED, 'Prefix process launch command with this string');
 }
开发者ID:dantleech,项目名称:phpbench,代码行数:18,代码来源:RunnerHandler.php

示例5: 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

示例6: addArgument

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

示例7: configure

 /**
  * {@inheritdoc}
  */
 public function configure(Command $command)
 {
     $command->addArgument(self::ARG_FILE, InputArgument::OPTIONAL, 'Load tests from a specific file or path.');
 }
开发者ID:phptest,项目名称:phptest,代码行数:7,代码来源:FileSystemController.php

示例8: addArgument

 public function addArgument($name, $mode = null, $description = '', $default = null)
 {
     return $this->innerCommand->addArgument($name, $mode, $description, $default);
 }
开发者ID:lolautruche,项目名称:ezsh,代码行数:4,代码来源:WrappedCommand.php

示例9: configure

 /**
  * Configures command to be able to process it later.
  *
  * @param Command $command
  */
 public function configure(Command $command)
 {
     $command->addArgument('features', InputArgument::OPTIONAL, "Feature(s) to run. Could be:" . "\n- a dir (<comment>src/to/Bundle/Features/</comment>), " . "\n- a feature (<comment>src/to/Bundle/Features/*.feature</comment>), " . "\n- a scenario at specific line (<comment>src/to/Bundle/Features/*.feature:10</comment>). " . "\n- Also, you can use short bundle notation (<comment>@BundleName/*.feature:10</comment>)");
 }
开发者ID:nmariani,项目名称:Symfony2Extension,代码行数:9,代码来源:LocatorProcessor.php

示例10: addArgument

 /**
  * @see Symfony\Component\Console\Command::addArgument This method is a proxy
  *
  * @return BuildStep
  */
 protected function addArgument(string $name, int $mode = null, string $description = '', $default = null)
 {
     $this->command->addArgument($name, $mode, $description, $default);
     return $this;
 }
开发者ID:alecgunnar,项目名称:maverick,代码行数:10,代码来源:BuildStep.php

示例11: argument

 /**
  * Add an argument to the command
  *
  * @return BaseCommand
  * @author Dan Cox
  */
 public function argument($name, $description, $required = 'required')
 {
     $argVal = array_key_exists($required, $this->argumentValueConstants) ? $this->argumentValueConstants[$required] : $required;
     parent::addArgument($name, $argVal, $description);
     return $this;
 }
开发者ID:danzabar,项目名称:alice,代码行数:12,代码来源:BaseCommand.php

示例12: configure

 /**
  * Configures command to be able to process it later.
  *
  * @param Command $command
  */
 public function configure(Command $command)
 {
     $command->addArgument('features', InputArgument::OPTIONAL, "Feature(s) to run. Could be:\n" . "- a dir <comment>(features/)</comment>\n" . "- a feature <comment>(*.feature)</comment>\n" . "- a scenario at specific line <comment>(*.feature:10)</comment>.\n" . "- all scenarios at or after a specific line <comment>(*.feature:10-*)</comment>.\n" . "- all scenarios at a line within a specific range <comment>(*.feature:10-20)</comment>.");
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:9,代码来源:LocatorProcessor.php

示例13: configure

 public function configure(Command $command)
 {
     $command->addArgument('features', InputArgument::OPTIONAL, "Feature(s) to run. Could be:" . "\n- a dir (<comment>src/to/Module/Features/</comment>), " . "\n- a feature (<comment>src/to/Module/Features/*.feature</comment>), ");
 }
开发者ID:inbaz,项目名称:zf2behat-extension,代码行数:4,代码来源:LocatorProcessor.php

示例14: 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

示例15: configure

 /**
  * Configures command to be executable by the controller.
  *
  * @param Command $command
  */
 public function configure(Command $command)
 {
     $command->addArgument('specs', InputArgument::REQUIRED, 'spec directory to run')->addOption('--dry-run', null, InputOption::VALUE_NONE, 'Invokes formatters without executing the steps & hooks.')->addOption('--strict', null, InputOption::VALUE_NONE, 'Fail if there are any undefined or pending steps.');
 }
开发者ID:docteurklein,项目名称:funk-spec,代码行数:9,代码来源:ExerciseController.php


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