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


PHP InputDefinition::addArgument方法代码示例

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


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

示例1: configure

 /**
  * @see Symfony\Component\Console\Command.Command::configure()
  */
 protected function configure()
 {
     $definition = new InputDefinition();
     $definition->addArgument(new InputArgument('namespace', InputArgument::REQUIRED, 'The namespace to process'));
     $definition->addArgument(new InputArgument('path', InputArgument::REQUIRED, 'The path the namespace can be found in'));
     $definition->addOption(new InputOption('output', 'o', InputOption::VALUE_REQUIRED, 'The path to output the ReST files', 'build'));
     $definition->addOption(new InputOption('title', 't', InputOption::VALUE_REQUIRED, 'An alternate title for the top level namespace', null));
     $definition->addOption(new InputOption('exclude', 'x', InputOption::VALUE_REQUIRED, 'Semicolon separated namespaces to ignore', null));
     $definition->addOption(new InputOption('filters', 'f', InputOption::VALUE_REQUIRED, 'Semicolon separated filename filters to apply', null));
     $this->setName('process')->setDescription('Processes a directory of PHPDoc documented code into ReST')->setHelp('The process command works recursively on a directory of PHP code.')->setDefinition($definition);
 }
开发者ID:victorhaggqvist,项目名称:sphpdox,代码行数:14,代码来源:Process.php

示例2: buildInputDefinition

 private function buildInputDefinition()
 {
     $inputDefinition = new InputDefinition();
     $inputDefinition->addArgument(new InputArgument('uno', InputArgument::REQUIRED));
     $inputDefinition->addOption(new InputOption('due', null, InputOption::VALUE_NONE));
     return $inputDefinition;
 }
开发者ID:Catapush,项目名称:Idephix,代码行数:7,代码来源:CommandWrapperTest.php

示例3: getInputDefinition

 /**
  * Get an InputDefinition formed by the arguments provided
  *
  * Effectively provides a passthrough for any input arguments provided
  *
  * @param  array  $args Arguments
  * @return InputDefinition
  */
 protected function getInputDefinition(array $args)
 {
     $definition = new InputDefinition();
     foreach ($args as $field => $value) {
         $definition->addArgument(new InputArgument($field));
     }
     return $definition;
 }
开发者ID:bodetree,项目名称:synapse-base,代码行数:16,代码来源:AbstractConsoleWork.php

示例4: testConfigureSystemCommand

 public function testConfigureSystemCommand()
 {
     $name = 'test_base_command';
     $description = 'test for base command creation';
     $keywords = 'base commands creation test';
     $arguments = array('username' => array('description' => 'linux username'));
     $options = 'options';
     $expectedArguments = new InputDefinition();
     $expectedArguments->addArgument(new InputArgument('username', InputArgument::REQUIRED, $arguments['username']['description']));
     $systemCommand = new SystemCommand($name, $description, $keywords, $arguments, $options);
     $this->assertEquals($expectedArguments, $systemCommand->getDefinition());
 }
开发者ID:PublicVar,项目名称:cop1,代码行数:12,代码来源:SystemCommandTest.php

示例5: run

 /**
  * @inheritdoc
  */
 public static function run($request, $response, $args)
 {
     global $argv;
     $container = static::getApp()->getContainer();
     $pathResolver = $container['pathResolver'];
     $filesystem = new Filesystem();
     $creator = new MigrationCreator($filesystem);
     $definition = new InputDefinition();
     $definition->addArgument(new InputArgument('name', InputArgument::REQUIRED));
     $definition->addOption(new InputOption('table', 't', InputOption::VALUE_OPTIONAL));
     $input = new ArgvInput(array_slice($argv, 1), $definition);
     $output = new ConsoleOutput();
     $path = $pathResolver->getAlias('@db/migrations');
     $name = $input->getArgument('name');
     $table = $input->getOption('table');
     $file = pathinfo($creator->create($name, $path, $table), PATHINFO_FILENAME);
     \dump($file);
 }
开发者ID:canis-io,项目名称:slim-laravel-helpers,代码行数:21,代码来源:Migration_CreateAction.php

示例6: configCommandAlias

 /**
  * @test
  */
 public function configCommandAlias()
 {
     $config = new Config();
     $input = new ArgvInput();
     $actual = $config->checkConfigCommandAlias($input);
     $this->assertInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface', $actual);
     $saved = $_SERVER['argv'];
     $config->setConfig(array('commands' => array('aliases' => array(array('list-help' => 'list --help')))));
     $definition = new InputDefinition();
     $definition->addArgument(new InputArgument('command'));
     $argv = array('/path/to/command', 'list-help');
     $_SERVER['argv'] = $argv;
     $input = new ArgvInput($argv, $definition);
     $this->assertSame('list-help', (string) $input);
     $actual = $config->checkConfigCommandAlias($input);
     $this->assertSame('list-help', $actual->getFirstArgument());
     $this->assertSame('list-help --help', (string) $actual);
     $_SERVER['argv'] = $saved;
     $command = new Command('list');
     $config->registerConfigCommandAlias($command);
     $this->assertSame(array('list-help'), $command->getAliases());
 }
开发者ID:netz98,项目名称:n98-magerun,代码行数:25,代码来源:ConfigTest.php

示例7: filterByOriginalDefinition

 /**
  * @param InputInterface $input
  * @param $appDefinition
  * @return ArrayInput
  */
 public function filterByOriginalDefinition(InputInterface $input, $appDefinition)
 {
     $newDefinition = new InputDefinition();
     $newInput = new ArrayInput(array(), $newDefinition);
     foreach ($input->getArguments() as $name => $value) {
         if (!$appDefinition->hasArgument($name)) {
             $newDefinition->addArgument($this->getDefinition()->getArgument($name));
             if (!empty($value)) {
                 $newInput->setArgument($name, $value);
             }
         }
     }
     foreach ($input->getOptions() as $name => $value) {
         if (!$appDefinition->hasOption($name)) {
             $newDefinition->addOption($this->getDefinition()->getOption($name));
             if (!empty($value)) {
                 $newInput->setOption($name, $value);
             }
         }
     }
     return $newInput;
 }
开发者ID:Catapush,项目名称:Idephix,代码行数:27,代码来源:CommandWrapper.php

示例8: setCommandConfig

 /**
  * Set command options/arguments
  * 
  * @return array
  */
 public function setCommandConfig()
 {
     $name = $this->config_name;
     // Конфиг. имя команды (пр. "my_greet")
     $definition = new Input\InputDefinition();
     //---------------------------
     $config = $this->app['config']['commands'][$name];
     // Set command description
     if ($config['configure']['description']) {
         $this->setDescription($config['configure']['description']);
     }
     // Set arguments
     if ($config['arguments']) {
         $arguments = $config['arguments'];
         foreach ($arguments as $argument) {
             $mode = $this->_getArgumentMode($argument['mode']);
             $newArgument = new InputArgument($argument['name'], $mode, $argument['description'], $argument['default']);
             $definition->addArgument($newArgument);
         }
     }
     // Set options
     if (isset($config['options'])) {
         $options = $config['options'];
         foreach ($options as $option) {
             $mode = $this->_getOptionMode($option['mode']);
             $newOption = new InputOption($option['name'], $option['shortcut'], $mode, $option['description'], $option['default']);
             $definition->addOption($newOption);
         }
     }
     $this->setDefinition($definition);
 }
开发者ID:bsa-git,项目名称:silex-mvc,代码行数:36,代码来源:BaseCommand.php

示例9: buildDefinition

 /**
  * Builds the Input Definition based upon Api Method Parameters.
  *
  * @param \ReflectionMethod $method
  * @param string            $token
  *
  * @return InputDefinition
  */
 private function buildDefinition(\ReflectionMethod $method, DocBlock $docBlock, $token = null)
 {
     $definition = new InputDefinition();
     foreach ($docBlock->getTags() as $tag) {
         if ($tag instanceof DocBlock\Tags\Param) {
             $tagsDescription[$tag->getVariableName()] = $tag->getDescription()->render();
         }
     }
     foreach ($method->getParameters() as $parameter) {
         if ($parameter->isDefaultValueAvailable()) {
             //option
             $definition->addOption(new InputOption($parameter->getName(), null, InputOption::VALUE_REQUIRED, $tagsDescription[$parameter->getName()], $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null));
         } else {
             //argument
             $definition->addArgument(new InputArgument($parameter->getName(), InputArgument::REQUIRED, $tagsDescription[$parameter->getName()], null));
         }
     }
     $definition->addOption(new InputOption('token', null, InputOption::VALUE_REQUIRED, 'Auth token to use', $token));
     $definition->addOption(new InputOption('debug', null, InputOption::VALUE_NONE, 'Display raw response'));
     return $definition;
 }
开发者ID:radutopala,项目名称:skype-bot-php,代码行数:29,代码来源:CommandFactory.php

示例10: testGetArgumentCount

 public function testGetArgumentCount()
 {
     $this->initializeArguments();
     $definition = new InputDefinition();
     $definition->addArgument($this->foo2);
     $this->assertEquals(1, $definition->getArgumentCount(), '->getArgumentCount() returns the number of arguments');
     $definition->addArgument($this->foo);
     $this->assertEquals(2, $definition->getArgumentCount(), '->getArgumentCount() returns the number of arguments');
 }
开发者ID:exDron,项目名称:AndrewBlog,代码行数:9,代码来源:InputDefinitionTest.php

示例11: bindSignature

 protected function bindSignature()
 {
     $signatureParts = new SignatureParts($this->signature);
     $signature = $signatureParts->getSignatureWithoutCommandName();
     list($name, $arguments, $options) = Parser::parse($signature);
     $this->name = $name;
     $inputDefinition = new InputDefinition();
     foreach ($arguments as $argument) {
         $inputDefinition->addArgument($argument);
     }
     foreach ($options as $option) {
         $inputDefinition->addOption($option);
     }
     $inputWithoutHandlerName = explode(' ', $this->request->text, 2)[1] ?? '';
     $this->input = new StringInput($inputWithoutHandlerName);
     $this->inputDefinition = $inputDefinition;
     try {
         $this->input->bind($inputDefinition);
     } catch (RuntimeException $exception) {
         return false;
     }
     return true;
 }
开发者ID:spatie,项目名称:laravel-slack-slash-command,代码行数:23,代码来源:SignatureHandler.php

示例12: InputDefinition

<?php

require __DIR__ . '/vendor/autoload.php';
use Elastica\Client;
use Elastica\Document;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
$inputDefinition = new InputDefinition();
$inputDefinition->addArgument(new InputArgument('host', InputArgument::REQUIRED));
$inputDefinition->addArgument(new InputArgument('tree', InputArgument::REQUIRED));
$options = [['port', null, InputOption::VALUE_REQUIRED, '', 9200], ['index', null, InputOption::VALUE_REQUIRED, '', 'test'], ['type', null, InputOption::VALUE_REQUIRED, '', 'test'], ['treeLevels', null, InputOption::VALUE_REQUIRED, '', null], ['precision', null, InputOption::VALUE_REQUIRED, '', null], ['tab', null, InputOption::VALUE_NONE], ['bulk-size', null, InputOption::VALUE_REQUIRED, '', 10]];
foreach ($options as $option) {
    $inputDefinition->addOption(new InputOption($option[0], $option[1], $option[2], $option[3], $option[4]));
}
$argvInput = new ArgvInput($argv, $inputDefinition);
$main = function () use($argvInput) {
    $host = $argvInput->getArgument('host');
    $port = $argvInput->getOption('port');
    $indexName = $argvInput->getOption('index');
    $typeName = $argvInput->getOption('type');
    $treeLevels = $argvInput->getOption('treeLevels');
    $precision = $argvInput->getOption('precision');
    $tree = $argvInput->getArgument('tree');
    $bulkSize = $argvInput->getOption('bulk-size');
    $tab = $argvInput->getOption('tab');
    if (!in_array($tree, ['quadtree', 'geohash'])) {
        throw new \Exception(sprintf('Supported tree types are quadtree and geohash, "%s" given.', $tree));
    }
    if (!isset($treeLevels) && !isset($precision)) {
开发者ID:bmichalski-poc,项目名称:php-elastic-geo-poc,代码行数:31,代码来源:geo-indexing-test.php

示例13: getDefinition

 /**
  * Add the retrieved options and arguments to a definition
  *
  * @return InputDefinition
  */
 public function getDefinition()
 {
     if (!$this->initialized) {
         $this->initialize();
     }
     $definition = new InputDefinition();
     foreach ($this->definitions as $from => $info) {
         $config = $info['config'];
         $required = array_key_exists('required', $config) && $config['required'];
         if ($info['type'] === 'option') {
             $mode = array_key_exists('mode', $config) ? $config['mode'] : InputOption::VALUE_OPTIONAL;
             if ($required) {
                 $mode |= InputOption::VALUE_REQUIRED;
             }
             if (in_array('array', explode('|', $config['type']), true)) {
                 $mode |= InputOption::VALUE_IS_ARRAY;
             }
             if (preg_match('/(^|\\|)bool(ean)?($|\\|)/', $config['type'])) {
                 if (strpos($config['type'], '|')) {
                     $mode |= InputOption::VALUE_NONE;
                 } else {
                     $mode = InputOption::VALUE_NONE;
                 }
             }
             $definition->addOption(new InputOption($from, array_key_exists('shortcut', $config) ? $config['shortcut'] : null, $mode, $config['label'], array_key_exists('default', $config) ? $config['default'] : null));
         } else {
             $mode = array_key_exists('mode', $config) ? $config['mode'] : InputArgument::OPTIONAL;
             if ($required) {
                 $mode |= InputArgument::REQUIRED;
             }
             if (in_array('array', explode('|', $config['type']), true)) {
                 $mode |= InputArgument::IS_ARRAY;
             }
             $definition->addArgument(new InputArgument($from, $mode, $config['label'], array_key_exists('default', $config) ? $config['default'] : null));
         }
     }
     return $definition;
 }
开发者ID:netresearch,项目名称:kite,代码行数:43,代码来源:Job.php

示例14: buildDefinition

 /**
  * builds the Input Definition based upon Api Method Parameters.
  *
  * @param \ReflectionMethod $method
  * @param string            $token
  *
  * @return InputDefinition
  */
 private function buildDefinition(\ReflectionMethod $method, $token = null)
 {
     $definition = new InputDefinition();
     foreach ($method->getParameters() as $parameter) {
         if ($parameter->isDefaultValueAvailable()) {
             //option
             $definition->addOption(new InputOption($parameter->getName(), null, InputOption::VALUE_REQUIRED, null, $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null));
         } else {
             //argument
             $definition->addArgument(new InputArgument($parameter->getName(), InputArgument::REQUIRED, null, null));
         }
     }
     $definition->addOption(new InputOption('token', null, InputOption::VALUE_REQUIRED, 'the auth token to use', $token));
     $definition->addOption(new InputOption('debug', null, InputOption::VALUE_NONE, 'display raw response'));
     return $definition;
 }
开发者ID:digitalkaoz,项目名称:versioneye-php,代码行数:24,代码来源:CommandFactory.php

示例15: addArgument

 /**
  * Adds an argument.
  *
  * @param string $name        The argument name
  * @param int    $mode        The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL
  * @param string $description A description text
  * @param mixed  $default     The default value (for InputArgument::OPTIONAL mode only)
  *
  * @return Command The current instance
  */
 public function addArgument($name, $mode = null, $description = '', $default = null)
 {
     $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
     return $this;
 }
开发者ID:fezfez,项目名称:symfony-console-di,代码行数:15,代码来源:SymfonyConsoleDiDto.php


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