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


PHP Question\ChoiceQuestion类代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $schoolId = $input->getOption('schoolId');
     if (!$schoolId) {
         $schoolTitles = [];
         foreach ($this->schoolManager->findBy([], ['title' => 'ASC']) as $school) {
             $schoolTitles[$school->getTitle()] = $school->getId();
         }
         $helper = $this->getHelper('question');
         $question = new ChoiceQuestion("What is this user's primary school?", array_keys($schoolTitles));
         $question->setErrorMessage('School %s is invalid.');
         $schoolTitle = $helper->ask($input, $output, $question);
         $schoolId = $schoolTitles[$schoolTitle];
     }
     $school = $this->schoolManager->findOneBy(['id' => $schoolId]);
     if (!$school) {
         throw new \Exception("School with id {$schoolId} could not be found.");
     }
     $userRecord = ['firstName' => $input->getOption('firstName'), 'lastName' => $input->getOption('lastName'), 'email' => $input->getOption('email'), 'telephoneNumber' => $input->getOption('telephoneNumber'), 'campusId' => $input->getOption('campusId'), 'username' => $input->getOption('username'), 'password' => $input->getOption('password')];
     $userRecord = $this->fillUserRecord($userRecord, $input, $output);
     $user = $this->userManager->findOneBy(['campusId' => $userRecord['campusId']]);
     if ($user) {
         throw new \Exception('User #' . $user->getId() . " with campus id {$userRecord['campusId']} already exists.");
     }
     $user = $this->userManager->findOneBy(['email' => $userRecord['email']]);
     if ($user) {
         throw new \Exception('User #' . $user->getId() . " with email address {$userRecord['email']} already exists.");
     }
     $table = new Table($output);
     $table->setHeaders(array('Campus ID', 'First', 'Last', 'Email', 'Username', 'Phone Number'))->setRows(array([$userRecord['campusId'], $userRecord['firstName'], $userRecord['lastName'], $userRecord['email'], $userRecord['username'], $userRecord['telephoneNumber']]));
     $table->render();
     $helper = $this->getHelper('question');
     $output->writeln('');
     $question = new ConfirmationQuestion("<question>Do you wish to add this user to Ilios in {$school->getTitle()}?</question>\n", true);
     if ($helper->ask($input, $output, $question)) {
         $user = $this->userManager->create();
         $user->setFirstName($userRecord['firstName']);
         $user->setLastName($userRecord['lastName']);
         $user->setEmail($userRecord['email']);
         $user->setCampusId($userRecord['campusId']);
         $user->setAddedViaIlios(true);
         $user->setEnabled(true);
         $user->setSchool($school);
         $user->setUserSyncIgnore(false);
         $this->userManager->update($user);
         $authentication = $this->authenticationManager->create();
         $authentication->setUsername($userRecord['username']);
         $user->setAuthentication($authentication);
         $encodedPassword = $this->encoder->encodePassword($user, $userRecord['password']);
         $authentication->setPasswordBcrypt($encodedPassword);
         $this->authenticationManager->update($authentication);
         $output->writeln('<info>Success! New user #' . $user->getId() . ' ' . $user->getFirstAndLastName() . ' created.</info>');
     } else {
         $output->writeln('<comment>Canceled.</comment>');
     }
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:59,代码来源:AddUserCommand.php

示例2: handle

 /**
  * {@inheritdoc}
  */
 protected function handle()
 {
     $plugins = elgg_get_plugins('inactive');
     if (empty($plugins)) {
         system_message('All plugins are active');
         return;
     }
     $ids = array_map(function (ElggPlugin $plugin) {
         return $plugin->getID();
     }, $plugins);
     $ids = array_values($ids);
     if ($this->option('all')) {
         $activate_ids = $ids;
     } else {
         $helper = $this->getHelper('question');
         $question = new ChoiceQuestion('Please select plugins you would like to activate (comma-separated list of indexes)', $ids);
         $question->setMultiselect(true);
         $activate_ids = $helper->ask($this->input, $this->output, $question);
     }
     if (empty($activate_ids)) {
         throw new \RuntimeException('You must select at least one plugin');
     }
     $plugins = [];
     foreach ($activate_ids as $plugin_id) {
         $plugins[] = elgg_get_plugin_from_id($plugin_id);
     }
     do {
         $additional_plugins_activated = false;
         foreach ($plugins as $key => $plugin) {
             if ($plugin->isActive()) {
                 unset($plugins[$key]);
                 continue;
             }
             if (!$plugin->activate()) {
                 // plugin could not be activated in this loop, maybe in the next loop
                 continue;
             }
             $ids = array('cannot_start' . $plugin->getID(), 'invalid_and_deactivated_' . $plugin->getID());
             foreach ($ids as $id) {
                 elgg_delete_admin_notice($id);
             }
             // mark that something has changed in this loop
             $additional_plugins_activated = true;
             unset($plugins[$key]);
             system_message("Plugin {$plugin->getFriendlyName()} has been activated");
         }
         if (!$additional_plugins_activated) {
             // no updates in this pass, break the loop
             break;
         }
     } while (count($plugins) > 0);
     if (count($plugins) > 0) {
         foreach ($plugins as $plugin) {
             $msg = $plugin->getError();
             $string = $msg ? 'admin:plugins:activate:no_with_msg' : 'admin:plugins:activate:no';
             register_error(elgg_echo($string, array($plugin->getFriendlyName())));
         }
     }
     elgg_flush_caches();
 }
开发者ID:hypejunction,项目名称:elgg-cli,代码行数:63,代码来源:PluginsActivateCommand.php

示例3: binaryInstallWindows

 /**
  * @param string          $path
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 protected function binaryInstallWindows($path, InputInterface $input, OutputInterface $output)
 {
     $php = Engine::factory();
     $table = new Table($output);
     $table->setRows([['<info>' . $php->getName() . ' Path</info>', $php->getPath()], ['<info>' . $php->getName() . ' Version</info>', $php->getVersion()], ['<info>Compiler</info>', $php->getCompiler()], ['<info>Architecture</info>', $php->getArchitecture()], ['<info>Thread safety</info>', $php->getZts() ? 'yes' : 'no'], ['<info>Extension dir</info>', $php->getExtensionDir()], ['<info>php.ini</info>', $php->getIniPath()]])->render();
     $inst = Install::factory($path);
     $progress = $this->getHelperSet()->get('progress');
     $inst->setProgress($progress);
     $inst->setInput($input);
     $inst->setOutput($output);
     $inst->install();
     $deps_handler = new Windows\DependencyLib($php);
     $deps_handler->setProgress($progress);
     $deps_handler->setInput($input);
     $deps_handler->setOutput($output);
     $helper = $this->getHelperSet()->get('question');
     $cb = function ($choices) use($helper, $input, $output) {
         $question = new ChoiceQuestion('Multiple choices found, please select the appropriate dependency package', $choices);
         $question->setMultiselect(false);
         return $helper->ask($input, $output, $question);
     };
     foreach ($inst->getExtDllPaths() as $dll) {
         if (!$deps_handler->resolveForBin($dll, $cb)) {
             throw new \Exception('Failed to resolve dependencies');
         }
     }
 }
开发者ID:jingdor,项目名称:pickle,代码行数:32,代码来源:InstallerCommand.php

示例4: interact

 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     if (trim($input->getOption('name')) == '') {
         $question = new Question\Question('Please enter the client name: ');
         $question->setValidator(function ($value) {
             if (trim($value) == '') {
                 throw new \Exception('The client name can not be empty');
             }
             $doctrine = $this->getContainer()->get('doctrine');
             $client = $doctrine->getRepository('AppBundle:Client')->findOneBy(['name' => $value]);
             if ($client instanceof \AppBundle\Entity\Client) {
                 throw new \Exception('The client name must be unique');
             }
             return $value;
         });
         $question->setMaxAttempts(5);
         $input->setOption('name', $helper->ask($input, $output, $question));
     }
     $grants = $input->getOption('grant-type');
     if (!(is_array($grants) && count($grants))) {
         $question = new Question\ChoiceQuestion('Please select the grant types (defaults to password and facebook_access_token): ', [\OAuth2\OAuth2::GRANT_TYPE_AUTH_CODE, \OAuth2\OAuth2::GRANT_TYPE_CLIENT_CREDENTIALS, \OAuth2\OAuth2::GRANT_TYPE_EXTENSIONS, \OAuth2\OAuth2::GRANT_TYPE_IMPLICIT, \OAuth2\OAuth2::GRANT_TYPE_REFRESH_TOKEN, \OAuth2\OAuth2::GRANT_TYPE_USER_CREDENTIALS, 'http://grants.api.schoolmanager.ledo.eu.org/facebook_access_token'], '5,6');
         $question->setMultiselect(true);
         $question->setMaxAttempts(5);
         $input->setOption('grant-type', $helper->ask($input, $output, $question));
     }
     parent::interact($input, $output);
 }
开发者ID:eduardoledo,项目名称:schoolmanager,代码行数:28,代码来源:ClientCreateCommand.php

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

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->setForce($input->getOption('force'));
     $this->setInput($input);
     $this->setOutput($output);
     $verbosityLevelMap = [LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL, LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL, LogLevel::DEBUG => OutputInterface::VERBOSITY_NORMAL];
     $consoleLogger = new ConsoleLogger($output, $verbosityLevelMap);
     $this->getContainer()->get('claroline.manager.user_manager')->setLogger($consoleLogger);
     $helper = $this->getHelper('question');
     //get excluding roles
     $roles = $this->getContainer()->get('claroline.persistence.object_manager')->getRepository('ClarolineCoreBundle:Role')->findAllPlatformRoles();
     $roleNames = array_map(function ($role) {
         return $role->getName();
     }, $roles);
     $roleNames[] = 'NONE';
     $all = $input->getOption('all');
     $questionString = $all ? 'Roles to exclude: ' : 'Roles to include: ';
     $question = new ChoiceQuestion($questionString, $roleNames);
     $question->setMultiselect(true);
     $roleNames = $helper->ask($input, $output, $question);
     $rolesSearch = array_filter($roles, function ($role) use($roleNames) {
         return in_array($role->getName(), $roleNames);
     });
     $this->deleteUsers($all, $rolesSearch);
 }
开发者ID:claroline,项目名称:distribution,代码行数:25,代码来源:RemoveUsersCommand.php

示例7: interact

 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the Symfony2Admingenerator');
     $output->writeln('<comment>Create an admingenerator bundle with generate:bundle</comment>');
     $generator = $input->getOption('generator');
     $question = new ChoiceQuestion('Generator to use (doctrine, doctrine_odm, propel)', array('doctrine', 'doctrine_odm', 'propel'), 0);
     $question->setErrorMessage('Generator to use have to be doctrine, doctrine_odm or propel.');
     $generator = $questionHelper->ask($input, $output, $question);
     $input->setOption('generator', $generator);
     // Model name
     $modelName = $input->getOption('model-name');
     $question = new Question($questionHelper->getQuestion('Model name', $modelName), $modelName);
     $question->setValidator(function ($answer) {
         if (empty($answer) || preg_match('#[^a-zA-Z0-9]#', $answer)) {
             throw new \RuntimeException('Model name should not contain any special characters nor spaces.');
         }
         return $answer;
     });
     $modelName = $questionHelper->ask($input, $output, $question);
     $input->setOption('model-name', $modelName);
     // prefix
     $prefix = $input->getOption('prefix');
     $question = new Question($questionHelper->getQuestion('Prefix of yaml', $prefix), $prefix);
     $question->setValidator(function ($prefix) {
         if (!preg_match('/([a-z]+)/i', $prefix)) {
             throw new \RuntimeException('Prefix have to be a simple word');
         }
         return $prefix;
     });
     $prefix = $questionHelper->ask($input, $output, $question);
     $input->setOption('prefix', $prefix);
     parent::interact($input, $output);
 }
开发者ID:Restless-ET,项目名称:GeneratorBundle,代码行数:34,代码来源:GenerateAdminCommand.php

示例8: showTasksToDelete

 protected function showTasksToDelete(InputInterface $input, OutputInterface $output, $tasks)
 {
     $helper = $this->getHelper('question');
     $question = new ChoiceQuestion('Please select the task that you want to delete', $tasks->toArray(), 0);
     $question->setErrorMessage('Task %s does not exist.');
     return $helper->ask($input, $output, $question);
 }
开发者ID:destebang,项目名称:taskreporter-1,代码行数:7,代码来源:DeleteTask.php

示例9: interact

 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $this->selectedSchema = $input->getArgument('name');
     if (!array_key_exists($this->selectedSchema, $this->schemaList)) {
         $question = new ChoiceQuestion('Please select of of the following templates:', array_keys($this->schemaList));
         $validator = function ($answer) use($output) {
             if (!array_key_exists($answer, $this->schemaList)) {
                 throw new \RuntimeException('The name of the template not found');
             }
             return $answer;
         };
         $question->setValidator($validator);
         $question->setMaxAttempts(2);
         $this->selectedSchema = $helper->ask($input, $output, $question);
     }
     $schema = $this->schemaList[$this->selectedSchema];
     foreach ($schema->getUndefinedVariables() as $var) {
         $question = new Question(sprintf('Please enter value for variable %s:', $var));
         $answer = $helper->ask($input, $output, $question);
         $schema->setVariable($var, $answer);
     }
     $dir = $input->getOption('dir');
     if (!$dir) {
         $dir = str_replace('\\', '/', $schema->getVariable('NAMESPACE'));
     }
     $this->selectedDir = trim($dir, '/\\');
 }
开发者ID:Joseki,项目名称:FileTemplate,代码行数:28,代码来源:ControlCommand.php

示例10: testAskChoice

    public function testAskChoice()
    {
        $questionHelper = new SymfonyQuestionHelper();

        $helperSet = new HelperSet(array(new FormatterHelper()));
        $questionHelper->setHelperSet($helperSet);

        $heroes = array('Superman', 'Batman', 'Spiderman');

        $inputStream = $this->getInputStream("\n1\n  1  \nFabien\n1\nFabien\n1\n0,2\n 0 , 2  \n\n\n");

        $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '2');
        $question->setMaxAttempts(1);
        // first answer is an empty answer, we're supposed to receive the default value
        $this->assertEquals('Spiderman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $output = $this->createOutputInterface(), $question));
        $this->assertOutputContains('What is your favorite superhero? [Spiderman]', $output);

        $question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
        $question->setMaxAttempts(1);
        $this->assertEquals('Batman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
        $this->assertEquals('Batman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));

        $question = new ChoiceQuestion('What is your favorite superhero?', $heroes);
        $question->setErrorMessage('Input "%s" is not a superhero!');
        $question->setMaxAttempts(2);
        $this->assertEquals('Batman', $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $output = $this->createOutputInterface(), $question));
        $this->assertOutputContains('Input "Fabien" is not a superhero!', $output);

        try {
            $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '1');
            $question->setMaxAttempts(1);
            $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $output = $this->createOutputInterface(), $question);
            $this->fail();
        } catch (\InvalidArgumentException $e) {
            $this->assertEquals('Value "Fabien" is invalid', $e->getMessage());
        }

        $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, null);
        $question->setMaxAttempts(1);
        $question->setMultiselect(true);

        $this->assertEquals(array('Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
        $this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));
        $this->assertEquals(array('Superman', 'Spiderman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $this->createOutputInterface(), $question));

        $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, '0,1');
        $question->setMaxAttempts(1);
        $question->setMultiselect(true);

        $this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $output = $this->createOutputInterface(), $question));
        $this->assertOutputContains('What is your favorite superhero? [Superman, Batman]', $output);

        $question = new ChoiceQuestion('What is your favorite superhero?', $heroes, ' 0 , 1 ');
        $question->setMaxAttempts(1);
        $question->setMultiselect(true);

        $this->assertEquals(array('Superman', 'Batman'), $questionHelper->ask($this->createStreamableInputInterfaceMock($inputStream), $output = $this->createOutputInterface(), $question));
        $this->assertOutputContains('What is your favorite superhero? [Superman, Batman]', $output);
    }
开发者ID:symfony,项目名称:symfony,代码行数:59,代码来源:SymfonyQuestionHelperTest.php

示例11: interact

 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $instance = $input->getArgument('instance');
     if (empty($instance)) {
         // find instances based on tag(s)
         $tags = $input->getOption('tag');
         $tags = $this->convertTags($tags);
         $repository = new Repository();
         $instanceCollection = $repository->findEc2InstancesByTags($tags);
         $count = count($instanceCollection);
         if ($count == 0) {
             throw new \Exception('No instance found matching the given tags');
         } elseif ($count == 1) {
             $instanceObj = $instanceCollection->getFirst();
             /* @var $instanceObj Instance */
             $input->setArgument('instance', $instanceObj->getInstanceId());
         } else {
             $mapping = [];
             // dynamically add current tags
             foreach (array_keys($tags) as $tagName) {
                 $mapping[$tagName] = 'Tags[?Key==`' . $tagName . '`].Value | [0]';
             }
             foreach ($input->getOption('column') as $tagName) {
                 $mapping[$tagName] = 'Tags[?Key==`' . $tagName . '`].Value | [0]';
             }
             $labels = [];
             foreach ($instanceCollection as $instanceObj) {
                 /* @var $instanceObj Instance */
                 $instanceLabel = $instanceObj->getInstanceId();
                 $tmp = [];
                 foreach ($instanceObj->extractData($mapping) as $field => $value) {
                     if (!empty($value)) {
                         $tmp[] = "{$field}: {$value}";
                     }
                 }
                 if (count($tmp)) {
                     $labels[] = $instanceLabel . ' (' . implode('; ', $tmp) . ')';
                 } else {
                     $labels[] = $instanceLabel;
                 }
             }
             $helper = $this->getHelper('question');
             $question = new ChoiceQuestion('Please select an instance', $labels);
             $question->setErrorMessage('Instance %s is invalid.');
             $instance = $helper->ask($input, $output, $question);
             $output->writeln('Selected Instance: ' . $instance);
             list($instance) = explode(' ', $instance);
             $input->setArgument('instance', $instance);
         }
     }
     if (!$input->getOption('force')) {
         $helper = $this->getHelper('question');
         $question = new ConfirmationQuestion("Are you sure you want to terminate following instance? {$instance} [y/N] ", false);
         if (!$helper->ask($input, $output, $question)) {
             throw new \Exception('Operation aborted');
         }
         $input->setOption('force', true);
     }
 }
开发者ID:aoepeople,项目名称:stackformation,代码行数:59,代码来源:TerminateCommand.php

示例12: getChoiceQuestion

 /**
  * {@inheritdoc}
  */
 protected function getChoiceQuestion()
 {
     // Translate the default into an array key.
     $defaultKey = $this->default !== null ? array_search($this->default, $this->options, true) : $this->default;
     $question = new ChoiceQuestion($this->name . " (enter a number to choose): ", $this->options, $defaultKey !== false ? $defaultKey : null);
     $question->setMaxAttempts($this->maxAttempts);
     return $question;
 }
开发者ID:pjcdawkins,项目名称:console-form,代码行数:11,代码来源:OptionsField.php

示例13: __construct

 public function __construct()
 {
     if (!$this->validate(App::get('in')->getOption('environment'))) {
         $question = new ChoiceQuestion('Do you want a development, test, or production environment?', ['development', 'test', 'production'], 'development');
         $question->setErrorMessage('%s is invalid.');
         $this->validate(App::get('io')->question($question));
     }
     App::get('io')->write("<comment>environment:</> <info>{$this->environment}</>");
 }
开发者ID:jeff-puckett,项目名称:mysql-dtp,代码行数:9,代码来源:Environment.php

示例14: execute

 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->elevateProcess($input, $output);
     $pid = null;
     $grep = $input->getArgument('grep');
     $command = new CommandBuilder('strace', '-f');
     $command->setOutputRedirect(CommandBuilder::OUTPUT_REDIRECT_ALL_STDOUT);
     $output->writeln('<h2>Starting process stracing</h2>');
     if (empty($pid)) {
         list($pidList, $processList) = $this->buildProcessList();
         if ($input->getOption('all')) {
             $pid = 'all';
         } else {
             try {
                 $question = new ChoiceQuestion('Please choose process for tracing', $processList);
                 $question->setMaxAttempts(1);
                 $questionDialog = new QuestionHelper();
                 $pid = $questionDialog->ask($input, $output, $question);
             } catch (\InvalidArgumentException $e) {
                 // Invalid value, just stop here
                 throw new \CliTools\Exception\StopException(1);
             }
         }
     }
     if (!empty($pid)) {
         switch ($pid) {
             case 'all':
                 $command->addArgumentTemplate('-p %s', implode(',', $pidList));
                 break;
             default:
                 $command->addArgumentTemplate('-p %s', $pid);
                 break;
         }
         // Stats
         if ($input->getOption('c')) {
             $command->addArgument('-c');
         }
         // Relative time
         if ($input->getOption('r')) {
             $command->addArgument('-r');
         } else {
             $command->addArgument('-tt');
         }
         // System trace filter
         if ($input->getOption('e')) {
             $command->addArgumentTemplate('-e %s', $input->getOption('e'));
         }
         // Add grep
         if (!empty($grep)) {
             $grepCommand = new CommandBuilder('grep');
             $grepCommand->addArgument('--color=auto')->addArgument($grep);
             $command->addPipeCommand($grepCommand);
         }
         $command->executeInteractive();
     }
     return 0;
 }
开发者ID:jousch,项目名称:clitools,代码行数:65,代码来源:AbstractTraceCommand.php

示例15: choice

 public function choice($question, array $choices, $default = null, $multiple = false)
 {
     if (null !== $default) {
         $values = array_flip($choices);
         $default = $values[$default];
     }
     $choiceQuestion = new ChoiceQuestion($question, $choices, $default);
     $choiceQuestion->setMultiselect($multiple);
     return $this->askQuestion($choiceQuestion);
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:10,代码来源:DrupalStyle.php


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