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


PHP InputInterface::hasArgument方法代码示例

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


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

示例1: checkArgumentCount

 protected static function checkArgumentCount(GeneratorInterface $generator, InputInterface $input)
 {
     $vars = $generator->getInputs();
     $positionals = array_filter($vars, function (InputTypeInterface $var) {
         return !$var->isOptional();
     });
     $found = false;
     if (count($positionals) === 0) {
         return false;
     }
     /** @var InputTypeInterface $var */
     foreach ($positionals as $var) {
         $name = $var->getArgumentName();
         if ($var->isMultiple() && !$var->isRequired() && !$input->hasArgument($name)) {
             $input->setArgument($name, array());
         }
         if (!$input->hasArgument($name) || $input->getArgument($name) === null) {
             if ($found) {
                 throw new \RuntimeException("Not enough arguments");
             } else {
                 break;
             }
         }
         $found = true;
     }
     return $found;
 }
开发者ID:tweedegolf,项目名称:generatorbundle,代码行数:27,代码来源:InputResultMatcher.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Parse the arguments.
     $this->venue = $input->getArgument('venue');
     if ($input->hasArgument('stock')) {
         $this->stock = $input->getArgument('stock');
     }
     if ($input->hasArgument('account')) {
         $this->account = $input->getArgument('account');
     }
     // Make sure the venue is up.
     $output->write('Making sure the venue is up... ');
     if ($this->venue()->heartbeat()) {
         $output->writeln('Yep!');
     } else {
         $output->writeln('Nope :(');
         throw new StockfighterSolutionException('The venue ' . $this->venue . ' is down or does not exist.');
     }
     // Run the inner execution.
     $result = $this->conduct($input, $output);
     if ($result !== null) {
         return $result;
     }
     // Run the loop.
     $this->stockfighter->run();
     return 0;
     // For success.
 }
开发者ID:sammarks,项目名称:stockfighter-solution-php,代码行数:28,代码来源:Command.php

示例3: initialize

 /**
  * @{inheritdoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     if ($input->hasArgument('service_name')) {
         $this->servicesName = array_map('trim', explode(',', $input->getArgument('service_name')));
     }
     if ($input->hasArgument('command_name')) {
         $this->serviceCommandName = $input->getArgument('command_name');
     }
 }
开发者ID:MatthieuPresse,项目名称:jarvis,代码行数:12,代码来源:ServiceCommand.php

示例4: execute

 /**
  * Execute command.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var Application $app */
     $app = $this->getApplication();
     $this->updateManager = $app->getSlicer()->getUpdateManager();
     if (NULL === $this->updateManager->getChangeProvider() && !$input->hasArgument('provider')) {
         throw new InvalidArgumentException('Change Provider must be specified either in slicer.json or as an argument');
     }
     if ($input->hasArgument('provider')) {
         $provider = $input->getArgument('provider');
         die($provider);
     }
     $start = $input->getArgument('starting-version');
     $end = $input->getArgument('ending-version');
     $result = $this->updateManager->createUpdate($start, $end);
 }
开发者ID:rawphp,项目名称:slicer,代码行数:24,代码来源:CreateCommand.php

示例5: guessBestTypo3BasePath

 /**
  * Guess best TYPO3 base path
  *
  * @param  string         $basePath     System base path
  * @param  InputInterface $input        Input instance
  * @param  null|string    $inputArgName Input option name for base path
  *
  * @return null|string
  * @throws \RuntimeException
  */
 public static function guessBestTypo3BasePath($basePath, $input = null, $inputArgName = null)
 {
     $ret = null;
     $userPath = null;
     if ($input !== null && $input instanceof InputInterface && $inputArgName !== null) {
         if ($input->hasArgument($inputArgName)) {
             $userPath = $input->getArgument($inputArgName);
         }
     }
     if (empty($userPath)) {
         // No user path specified, only use base path
         $ret = $basePath;
     } else {
         // check if path is an absolute path
         if (strpos($userPath, '/') === 0) {
             $ret = $userPath;
         } else {
             // relative path? try to guess the best match
             $guessPath = $basePath . '/' . $userPath;
             if (is_dir($guessPath)) {
                 $ret = $guessPath;
             }
         }
     }
     if ($ret === null) {
         throw new \RuntimeException('Could not guess TYPO3 base path');
     }
     return $ret;
 }
开发者ID:jousch,项目名称:clitools,代码行数:39,代码来源:Typo3Utility.php

示例6: interact

 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the Doctrine2 CRUD generator');
     // namespace
     $output->writeln(array('', 'This command helps you generate CRUD controllers and templates.', '', 'First, you need to give the entity for which you want to generate a CRUD.', 'You can give an entity that does not exist yet and the wizard will help', 'you defining it.', '', 'You must use the shortcut notation like <comment>AcmeBlogBundle:Post</comment>.', ''));
     if ($input->hasArgument('entity') && $input->getArgument('entity') != '') {
         $input->setOption('entity', $input->getArgument('entity'));
     }
     $question = new Question($questionHelper->getQuestion('The Entity shortcut name', $input->getOption('entity')), $input->getOption('entity'));
     $question->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
     $autocompleter = new EntitiesAutoCompleter($this->getContainer()->get('doctrine')->getManager());
     $autocompleteEntities = $autocompleter->getSuggestions();
     $question->setAutocompleterValues($autocompleteEntities);
     $entity = $questionHelper->ask($input, $output, $question);
     $input->setOption('entity', $entity);
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     // write?
     $withWrite = 'yes';
     $input->setOption('with-write', $withWrite);
     // format
     $format = 'annotation';
     $input->setOption('format', $format);
     // route prefix
     $prefix = $this->getRoutePrefix($input, $entity);
     $output->writeln(array('', 'Determine the routes prefix (all the routes will be "mounted" under this', 'prefix: /prefix/, /prefix/new, ...).', ''));
     $prefix = $questionHelper->ask($input, $output, new Question($questionHelper->getQuestion('Routes prefix', '/' . $prefix), '/' . $prefix));
     $input->setOption('route-prefix', $prefix);
     // summary
     $output->writeln(array('', $this->getHelper('formatter')->formatBlock('Summary before generation', 'bg=blue;fg=white', true), '', sprintf("You are going to generate a CRUD controller for \"<info>%s:%s</info>\"", $bundle, $entity), sprintf("using the \"<info>%s</info>\" format.", $format), ''));
 }
开发者ID:blacksad12,项目名称:oliorga,代码行数:31,代码来源:GenerateDoctrineCrudCommand.php

示例7: execute

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $log = new Logger('dns-updater');
     $log->pushHandler(new StreamHandler(__DIR__ . '/application.log', Logger::INFO));
     if ($input->hasArgument('name') && !empty($input->getArgument('name'))) {
         $names = [$input->getArgument('name')];
     } else {
         $names = $this->getConfig('dns_records');
     }
     $externalIp = $this->getExternalIp();
     $output->writeln("<info>External IP queried: " . $externalIp . '</info>');
     if ($this->hasIpChanged($externalIp)) {
         $this->storeIp($externalIp);
         $output->writeln(sprintf('<info>External ip %s has been changed, starting dns update</info>', $externalIp));
         $log->addInfo(sprintf('External ip %s has been changed, starting dns update', $externalIp));
         foreach ($names as $name) {
             if (!empty($name)) {
                 $response = $this->removeDnsRecord($name);
                 if ($response) {
                     $output->writeln('<info>Removed dns record: ' . $name . '</info>');
                     $this->addDnsRecord($name, $externalIp);
                     if ($response) {
                         $output->writeln('<info>Added dns record: ' . $name . ' with ip ' . $externalIp . '</info>');
                     } else {
                         $output->writeln('<error>Error while removing dns record: ' . $name . '</error>');
                     }
                 } else {
                     $output->writeln('<error>Error while removing dns record: ' . $name . '</error>');
                 }
             }
         }
     } else {
         $output->writeln(sprintf("<info>External ip %s matches stored ip address %s, skipping dns update</info>", $externalIp, $this->getStoredIp()));
     }
 }
开发者ID:pegasuz,项目名称:dns-updater,代码行数:40,代码来源:UpdateCommand.php

示例8: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     /** @var StorageInterface $storage */
     $storage = $this->getContainer()->get('storage');
     $files = $input->getArgument('files');
     if ($input->getOption('latest')) {
         $remoteFiles = $storage->remoteListing();
         if (count($remoteFiles) > 0) {
             $files[] = end($remoteFiles);
             $input->setArgument('files', $files);
         }
     }
     if ($input->hasArgument('files') && !empty($files)) {
         return;
     }
     $remoteFiles = $storage->remoteListing();
     $localFiles = $storage->localListing();
     if (count(array_diff($remoteFiles, $localFiles)) === 0) {
         $output->writeln('All files fetched');
         return;
     }
     $helper = $this->getHelper('question');
     $question = new ChoiceQuestion('Which backup', array_values(array_diff($remoteFiles, $localFiles)));
     $question->setMultiselect(true);
     $question->setErrorMessage('Backup %s is invalid.');
     $question->setAutocompleterValues([]);
     $input->setArgument('files', $helper->ask($input, $output, $question));
 }
开发者ID:nanbando,项目名称:core,代码行数:31,代码来源:FetchCommand.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $message = $this->getMessageHelper();
     $file = null;
     if ($input->hasArgument('file')) {
         $file = $input->getArgument('file');
     }
     if (!file_exists($file)) {
         $message->addErrorMessage(sprintf($this->trans('commands.migrate.load.messages.invalid_file'), $file));
         return 1;
     }
     if ($this->migration_id_found === false) {
         $migration_entity = $this->generateEntity($this->file_data, 'migration');
         if ($migration_entity->isInstallable()) {
             $migration_entity->trustData()->save();
             $output->writeln('[+] <info>' . sprintf($this->trans('commands.migrate.load.messages.installed') . '</info>'));
         }
     }
     $override = $input->getOption('override');
     if ($override === 'yes') {
         $migration_updated = $this->updateEntity($this->file_data['id'], 'migration', $this->file_data);
         $migration_updated->trustData()->save();
         $output->writeln('[+] <info>' . sprintf($this->trans('commands.migrate.load.messages.overridden') . '</info>'));
     }
 }
开发者ID:rmelike,项目名称:DrupalConsole,代码行数:28,代码来源:MigrateLoadCommand.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $toReindex = [];
     if ($input->hasArgument('entityName')) {
         $filter = $this->getEntityManager()->getRepository($input->getArgument('entityName'))->getClassName();
     } else {
         $filter = null;
     }
     foreach ($this->getEntityClasses() as $class) {
         if (!$filter || $class === $filter) {
             $toReindex[] = $class;
         }
     }
     $nIndexed = 0;
     foreach ($toReindex as $className) {
         $nIndexed += $this->clear($className);
     }
     switch ($nIndexed) {
         case 0:
             $output->writeln('No entity cleared');
             break;
         case 1:
             $output->writeln('<info>1</info> entity cleared');
             break;
         default:
             $output->writeln(sprintf('<info>%s</info> entities cleared', $nIndexed));
             break;
     }
 }
开发者ID:AdrenalineHunter,项目名称:AlgoliaSearchBundle,代码行数:29,代码来源:ClearCommand.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(Input $input, Output $output)
 {
     $stage = $input->hasArgument('stage') ? $input->getArgument('stage') : null;
     $tasks = $this->deployer->getScriptManager()->getTasks($this->getName(), $stage);
     $servers = $this->deployer->getStageStrategy()->getServers($stage);
     $environments = iterator_to_array($this->deployer->environments);
     if (isset($this->executor)) {
         $executor = $this->executor;
     } else {
         if ($input->getOption('parallel')) {
             $executor = new ParallelExecutor($this->deployer->getConsole()->getUserDefinition());
         } else {
             $executor = new SeriesExecutor();
         }
     }
     try {
         $executor->run($tasks, $servers, $environments, $input, $output);
     } catch (\Exception $exception) {
         \Deployer\logger($exception->getMessage(), Logger::ERROR);
         // Check if we have tasks to execute on failure.
         if ($this->deployer['onFailure']->has($this->getName())) {
             $taskName = $this->deployer['onFailure']->get($this->getName());
             $tasks = $this->deployer->getScriptManager()->getTasks($taskName, $stage);
             $executor->run($tasks, $servers, $environments, $input, $output);
         }
         throw $exception;
     }
     if (Deployer::hasDefault('terminate_message')) {
         $output->writeln(Deployer::getDefault('terminate_message'));
     }
 }
开发者ID:elfet,项目名称:deployer,代码行数:34,代码来源:TaskCommand.php

示例12: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $identifier = $input->getArgument('identifier');
     $product = $this->getProduct($identifier);
     if (null === $product) {
         $output->writeln(sprintf('<error>Product with identifier "%s" not found</error>', $identifier));
         return -1;
     }
     if ($input->hasArgument('username') && '' != ($username = $input->getArgument('username'))) {
         if (!$this->createToken($output, $username)) {
             return -1;
         }
     }
     $updates = json_decode($input->getArgument('json_updates'), true);
     $this->update($product, $updates);
     $violations = $this->validate($product);
     foreach ($violations as $violation) {
         $output->writeln(sprintf("<error>%s</error>", $violation->getMessage()));
     }
     if (0 !== $violations->count()) {
         $output->writeln(sprintf('<error>Product "%s" is not valid</error>', $identifier));
         return -1;
     }
     $this->save($product);
     $output->writeln(sprintf('<info>Product "%s" has been updated</info>', $identifier));
     return 0;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:30,代码来源:UpdateProductCommand.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     try {
         $settings = new PhpParallelLint\Settings();
         //$output->writeln("Hola");
         if ($input->hasArgument("directory")) {
             $settings->paths = $input->getArgument("directory");
         }
         if ($input->hasOption("exclude")) {
             $settings->excluded = $input->getOption("exclude");
         }
         if ($input->hasOption("extension")) {
             $settings->extensions = $input->getOption("extension");
         }
         if ($input->hasOption("number-jobs")) {
             $settings->parallelJobs = $input->getOption("number-jobs");
         }
         if ($input->hasOption("no-colors")) {
             $settings->colors = false;
         }
         $manager = new PhpParallelLint\Manager();
         $result = $manager->run($settings);
     } catch (Exception $e) {
     }
 }
开发者ID:rebangm,项目名称:php-checker,代码行数:25,代码来源:ParallelLintCommand.php

示例14: execute

 protected function execute(InputInterface $input)
 {
     $input->getArgument("<getArgument>");
     $input->hasArgument("<hasArgument>");
     $input->getOption("<getOption>");
     $input->hasOption("<hasOption>");
 }
开发者ID:moukail,项目名称:idea-php-symfony2-plugin,代码行数:7,代码来源:FooCommand.php

示例15: interact

 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the Parse.com CRUD generator');
     // namespace
     $output->writeln(array('', 'This command helps you generate CRUD controllers and templates.', 'You must use the shortcut notation like <comment>AcmeBlogBundle:Post</comment>.', ''));
     if ($input->hasArgument('parse-entity-name') && $input->getArgument('parse-entity-name') != '') {
         $input->setOption('parse-entity-name', $input->getArgument('parse-entity-name'));
     }
     $question = new Question($questionHelper->getQuestion('The Entity shortcut name', $input->getOption('parse-entity-name')), $input->getOption('parse-entity-name'));
     $question->setValidator(array('BcTic\\ParseCrudGenerator\\CrudGeneratorBundle\\Command\\Validators', 'validateParseEntityName'));
     $autocompleter = new EntitiesAutoCompleter($this->getContainer()->get('doctrine')->getManager());
     $autocompleteEntities = $autocompleter->getSuggestions();
     $question->setAutocompleterValues($autocompleteEntities);
     $entity = $questionHelper->ask($input, $output, $question);
     $input->setOption('parse-entity-name', $entity);
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     // route prefix
     $prefix = $this->getRoutePrefix($input, $entity);
     $output->writeln(array('', 'Determine the routes prefix (all the routes will be "mounted" under this', 'prefix: /prefix/, /prefix/new, ...).', ''));
     $prefix = $questionHelper->ask($input, $output, new Question($questionHelper->getQuestion('Routes prefix', '/' . $prefix), '/' . $prefix));
     $input->setOption('route-prefix', $prefix);
     // summary
     $output->writeln(array('', $this->getHelper('formatter')->formatBlock('Summary before generation', 'bg=blue;fg=white', true), '', sprintf("You are going to generate a CRUD controller for \"<info>%s:%s</info>\"", $bundle, $entity), ''));
 }
开发者ID:mliell,项目名称:symfony-parse-crud-generator,代码行数:25,代码来源:GenerateParseCrudCommand.php


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