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


PHP DialogHelper::ask方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     $note = $input->getArgument('note');
     // fb note "string message" and so we swap case and note
     if (!is_numeric($case)) {
         $note = $case;
         $case = $this->app->getCurrent();
         if (empty($case)) {
             $case = $dialog->ask($output, 'Enter a case number:');
         }
     }
     if (empty($note)) {
         $note = $dialog->ask($output, sprintf("Please supply a note for Case %d:\n", $case));
     }
     try {
         $this->app->fogbugz->edit(array('ixBug' => $case, 'sEvent' => $note));
         $output->writeln(sprintf('Left a note on case %s', $case), $this->app->outputFormat);
     } catch (ApiError $e) {
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()), $this->app->outputFormat);
         exit(1);
     }
 }
开发者ID:enobrev,项目名称:fogbugz-php-cli,代码行数:25,代码来源:NoteCommand.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     // TODO: this should be config dir
     if (file_exists($this->app->configFile)) {
         $this->config = Yaml::parse($this->app->configFile);
     } else {
         $this->config = $this->app->getDefaultConfig();
     }
     $output->writeln(sprintf("%s\n<info>%s</info>\n%s\n Config Path: %s\n", str_repeat("—", 80), str_pad("FogBugz Client Setup", 80, " ", STR_PAD_BOTH), str_repeat("—", 80), $this->app->configFile), $this->app->outputFormat);
     // Prompt the values in the config file
     $question = "Enable color output (";
     $question .= !empty($this->config['UseColor']) && $this->config['UseColor'] ? "yes" : "no";
     $question .= "): ";
     $useColor = $dialog->ask($output, $question, $this->config['UseColor']);
     $this->config['UseColor'] = strtolower($useColor[0]) == 'y';
     // TODO: use validation here for host prompt
     $question = "FogBugz host url (";
     $question .= !empty($this->config['Host']) && $this->config['Host'] ? $this->config['Host'] : "include https://";
     $question .= "): ";
     $this->config['Host'] = $dialog->ask($output, $question, $this->config['Host']);
     // We can use this config to know if we need to make changes in setup
     $this->config['ConfigVersion'] = $this->app->project->version;
     $this->app->config = $this->config;
     $this->app->saveConfig();
     // Display the alias to use in bash config.
 }
开发者ID:enobrev,项目名称:fogbugz-php-cli,代码行数:28,代码来源:SetupCommand.php

示例3: testAsk

 public function testAsk()
 {
     $dialog = new DialogHelper();
     $dialog->setInputStream($this->getInputStream("\n8AM\n"));
     $this->assertEquals('2PM', $dialog->ask($this->getOutputStream(), 'What time is it?', '2PM'));
     $this->assertEquals('8AM', $dialog->ask($output = $this->getOutputStream(), 'What time is it?', '2PM'));
     rewind($output->getStream());
     $this->assertEquals('What time is it?', stream_get_contents($output->getStream()));
 }
开发者ID:laiello,项目名称:masfletes,代码行数:9,代码来源:DialogHelperTest.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     $note = $input->getArgument('note');
     // fb note "string message" and so we swap case and note
     if (!is_numeric($case)) {
         $note = $case;
         $case = $this->app->getCurrent();
         if (empty($case)) {
             $case = $dialog->ask($output, "Enter a case number:");
         } else {
             $output->writeln(sprintf("<notice>Resolving current Case %d.</notice>", $case), $this->app->outputFormat);
         }
     }
     $category = $this->app->fogbugz->search(array('q' => (int) $case, 'cols' => 'ixCategory'));
     $category = (int) $category->cases->case->ixCategory;
     $statuses = $this->app->fogbugz->listStatuses(array('fResolved' => 1, 'ixCategory' => (int) $category));
     foreach ($statuses->statuses->status as $status) {
         $output->writeln(sprintf("  <info>[%d]</info> %s", $status->ixStatus, $status->sStatus), $this->app->outputFormat);
     }
     $status = "";
     while (!is_numeric($status)) {
         $status = $dialog->ask($output, 'Enter the status from the list above: ');
     }
     $activePeople = $this->app->fogbugz->listPeople(array('fIncludeActive' => 1));
     $virtualPeople = $this->app->fogbugz->listPeople(array('fIncludeVirtual' => 1));
     $output->writeln('<alert>Active Users</alert>');
     $i = 1;
     foreach (array($activePeople, $virtualPeople) as $people) {
         foreach ($people->people->person as $person) {
             $output->writeln(sprintf("  <info>[%s%d]</info> %s", strlen($person->ixPerson) - 1 ? '' : ' ', $person->ixPerson, $person->sFullName), $this->app->outputFormat);
         }
         $i && $output->writeln('<alert>Virtual Users</alert>');
         $i--;
     }
     // TODO: validate the `assignedto` var.
     $assignedto = $dialog->ask($output, "Who should the case be assigned to: ");
     if (empty($note)) {
         $note = $dialog->ask($output, sprintf("Please supply a note for Case %d (optional):\n", $case));
     }
     $request = array('ixStatus' => $status, 'ixBug' => $case, 'ixPersonAssignedTo' => $assignedto, 'sEvent' => empty($note) ? '' : $note);
     try {
         $this->app->fogbugz->resolve($request);
         printf("Resolved case %s\n", $case);
     } catch (ApiError $e) {
         $output->writeln(sprintf("<error>%s</error>", $e->getMessage()), $this->app->outputFormat);
         exit(1);
     }
 }
开发者ID:enobrev,项目名称:fogbugz-php-cli,代码行数:51,代码来源:ResolveCommand.php

示例5: interact

 public function interact(DialogHelper $dialog, OutputInterface $output, array $answers)
 {
     #Database user Name
     $answers['username'] = $dialog->ask($output, '<question>What is the Database user name? [false] : </question>', false);
     #Database user Password
     $answers['password'] = $dialog->ask($output, '<question>What is the Database users password? [false] : </question>', false);
     if ($dialog->askConfirmation($output, '<question>Using in memory database? [y|n] : </question>', false)) {
         $answers['memory'] = ':memory';
     } else {
         #Database path
         $answers['path'] = $dialog->ask($output, '<question>What is the Database path relative to project root? : </question>', false);
     }
     return $answers;
 }
开发者ID:icomefromthenet,项目名称:faker,代码行数:14,代码来源:Sqlite.php

示例6: interact

 public function interact(DialogHelper $dialog, OutputInterface $output, array $answers)
 {
     # Ask Database Schema Name
     $answers['schema'] = $dialog->ask($output, '<question>What is the Database schema name? : </question>');
     #Database user Name
     $answers['username'] = $dialog->ask($output, '<question>What is the Database user name? : </question>');
     #Database user Password
     $answers['password'] = $dialog->ask($output, '<question>What is the Database users password? : </question>');
     #Database host
     $answers['host'] = $dialog->ask($output, '<question>What is the Database host name? [localhost] : </question>', 'localhost');
     #Database port
     $answers['port'] = $dialog->ask($output, '<question>What is the Database port? [3306] : </question>', 3306);
     return $answers;
 }
开发者ID:icomefromthenet,项目名称:faker,代码行数:14,代码来源:Sqlsrv.php

示例7: testAskWithAutocomplete

 public function testAskWithAutocomplete()
 {
     if (!$this->hasSttyAvailable()) {
         $this->markTestSkipped('`stty` is required to test autocomplete functionality');
     }
     // Acm<NEWLINE>
     // Ac<BACKSPACE><BACKSPACE>s<TAB>Test<NEWLINE>
     // <NEWLINE>
     // <UP ARROW><UP ARROW><NEWLINE>
     // <UP ARROW><UP ARROW><UP ARROW><UP ARROW><UP ARROW><TAB>Test<NEWLINE>
     // <DOWN ARROW><NEWLINE>
     // S<BACKSPACE><BACKSPACE><DOWN ARROW><DOWN ARROW><NEWLINE>
     // F00<BACKSPACE><BACKSPACE>oo<TAB><NEWLINE>
     $inputStream = $this->getInputStream("Acm\nAcs\tTest\n\n[A[A\n[A[A[A[A[A\tTest\n[B\nS[B[B\nF00oo\t\n");
     $dialog = new DialogHelper();
     $dialog->setInputStream($inputStream);
     $bundles = array('AcmeDemoBundle', 'AsseticBundle', 'SecurityBundle', 'FooBundle');
     $this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
     $this->assertEquals('AsseticBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
     $this->assertEquals('FrameworkBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
     $this->assertEquals('SecurityBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
     $this->assertEquals('FooBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
     $this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
     $this->assertEquals('AsseticBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
     $this->assertEquals('FooBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles));
 }
开发者ID:d3ancole1995,项目名称:symfony,代码行数:26,代码来源:DialogHelperTest.php

示例8: askAuth

 public function askAuth()
 {
     $dialog = new DialogHelper();
     self::$user = $dialog->ask($this->getOutput(), "<question>GitHub User</question> ");
     self::$pass = $dialog->askHiddenResponse($this->getOutput(), "   <question>Password</question> ");
     return $this;
 }
开发者ID:sliver,项目名称:Robo,代码行数:7,代码来源:GitHub.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     if (null == $case) {
         $case = $this->app->getCurrent();
         if ($case == null || $case == 0) {
             $case = $dialog->ask($output, 'Enter a case number: ');
         }
     }
     try {
         $bug = $this->app->fogbugz->search(array('q' => (int) $case, 'cols' => 'ixBug,sTitle,sStatus,sLatestTextSummary,' . 'sProject,sArea,sPersonAssignedTo,sStatus,' . 'sPriority,sCategory,dtOpened,dtResolved,' . 'dtClosed,dtLastUpdated,sFixFor,ixBugParent'));
     } catch (ApiError $e) {
         $output->writeln(sprintf("<error>%s</error>", $e->getMessage()), $this->app->outputFormat);
         exit(1);
     }
     if (0 == $bug->cases['count']) {
         $output->writeln(sprintf('<error>Unable to retrieve [%d]</error>', $case), $this->app->outputFormat);
         exit(1);
     }
     // extract the case to local vars and then include the template
     $data = FogBugzHelpers::responseToArray($bug->cases->case);
     $data['host'] = $this->app->fogbugz->url;
     if ($data['ixBugParent'] == 0) {
         $data['ixBugParent'] = '—';
     }
     $data['statusFormat'] = $this->app->statusStyle($data['sStatus']);
     $template = $this->app->twig->loadTemplate('info.twig');
     $view = $template->render($data);
     $output->write($view, false, $this->app->outputFormat);
 }
开发者ID:enobrev,项目名称:fogbugz-php-cli,代码行数:32,代码来源:ViewCommand.php

示例10: createInstance

 protected function createInstance()
 {
     $entities = entity_get_info();
     $entityList = array_keys($entities);
     $entity = $this->dialog->select($this->output, 'What entity? ', $entityList);
     $entity = $entityList[$entity];
     $bundles = field_info_bundles($entity);
     $bundleList = array_keys($bundles);
     $bundle = $this->dialog->select($this->output, 'What bundle? ', $bundleList);
     $bundle = $bundleList[$bundle];
     $field_types = FieldBuilder::getFields();
     $fieldList = array();
     foreach ($field_types as $field => $definition) {
         $fieldList[$field] = sprintf("%s (%s)", $definition['label'], $field);
     }
     $fieldValues = array_keys($field_types);
     $field = $this->dialog->select($this->output, 'Field To Attach', array_values($fieldList));
     $field = $fieldValues[$field];
     $widget_types = WidgetBuilder::getTypesForFieldType($field_types[$field]['type']);
     $widgetList = array_keys($widget_types);
     $widget = $this->dialog->select($this->output, 'Widget to Use', array_values($widget_types));
     $widget = $widgetList[$widget];
     $label = $this->dialog->ask($this->output, 'What label for this instance? ');
     $widgetDefinition = new WidgetBuilder($widget, $label);
     $builder = new InstanceBuilder($field, $label, $widgetDefinition);
     $builder->build($entity, $bundle);
     $this->output->writeln("Created instance of field {$field} with label <info>{$label}</info> on {$entity}:{$bundle}");
     $this->mainQuestion();
 }
开发者ID:wesnick,项目名称:drupal-bootstrap,代码行数:29,代码来源:SiteBuilderCommand.php

示例11: getDbService

 /**
  * Create DbService instance based on CLI options, prompt for pass
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return DbService
  */
 private function getDbService(InputInterface $input, OutputInterface $output)
 {
     $base = $input->getOption('base');
     if (!$base) {
         $output->writeln('<error>Missing base DB name</error>');
         return null;
     }
     $this->arguments['base'] = $base;
     $this->arguments['host'] = $input->getOption('host');
     $this->arguments['username'] = $input->getOption('username');
     $this->arguments['file'] = $input->getOption('file');
     $this->arguments['password'] = (string) $this->dialog->askHiddenResponse($output, '<question>Please enter the DB password (default "")</question>', $this->arguments['password']);
     $target = $input->getOption('target');
     $schemaFile = null;
     if (!$target) {
         $target = 'compare_' . date('YmdHis');
         $output->writeln(sprintf('<info>Missing target DB name - creating schema %s</info>', $target));
         $schemaFile = $this->dialog->ask($output, '<question>File to create base schema</question>', null);
         if (!$schemaFile || !file_exists($schemaFile)) {
             $output->writeln(sprintf('<error>Invalid schema file: %s</error>', $schemaFile));
             return null;
         }
     }
     $this->arguments['target'] = $target;
     $service = new DbService($this->arguments['host'], $this->arguments['username'], $this->arguments['password'], $this->arguments['base'], $this->arguments['target']);
     $this->dropSchema = $schemaFile !== null;
     //ensure schemas exist, create target schema if required
     $service->checkSchemas($this->dropSchema);
     if ($schemaFile) {
         $service->loadTargetSchema($schemaFile);
     }
     return $service;
 }
开发者ID:EVODelavega,项目名称:mysql-diff,代码行数:39,代码来源:CompareCommand.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     if (!empty($this->app->config['AuthToken'])) {
         $this->app->fogbugz = new FogBugz\Api($this->app->config['User'], '', $this->app->config['Host']);
         // The api used to login on instantiation, now we keep this token
         $this->app->fogbugz->token = $this->app->config['AuthToken'];
         if (!$input->getOption('quiet')) {
             $output->writeln("\nYou're already in as <info>" . $this->app->config['User'] . "</info>.\nUse the logout command to terminate this session.\n");
         }
         // TODO: Test this token, and re-prompt if it fails
         return;
     }
     $output->writeln("\n<comment>Please Login to FogBugz</comment>");
     $user = $dialog->ask($output, " * Email address: ", getenv("GIT_AUTHOR_EMAIL"));
     $password = $this->promptSilent(" * Password: ");
     $this->app->fogbugz = new FogBugz\Api($user, $password, $this->app->config['Host']);
     try {
         $this->app->fogbugz->logon();
         $this->app->config = array_merge($this->app->config, array('User' => $user, 'AuthToken' => $this->app->fogbugz->token));
         $this->app->saveConfig();
         $output->writeln("   <info>You're in. Use the logout command to terminate this session.</info>");
     } catch (FogBugz\ApiLogonError $e) {
         $output->writeln("\n<error>" . $e->getMessage() . "</error>\n");
         exit(1);
     }
     // Write the config and the token out to the config file
 }
开发者ID:enobrev,项目名称:fogbugz-php-cli,代码行数:29,代码来源:LoginCommand.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     if (null == $case) {
         $case = $this->app->getCurrent();
         if ($case == null || $case == 0) {
             $case = $dialog->ask($output, "Enter a case number: ");
         }
     }
     $url = trim($this->app->fogbugz->url, "/") . "/default.asp?" . $case;
     switch (PHP_OS) {
         case 'Darwin':
             exec("open {$url}");
             break;
         case 'WIN32':
         case 'WINNT':
             exec("cmd /c \"start {$url}\"");
             break;
         case 'Linux':
         case 'Unix':
         case 'NetBSD':
         case 'OpenBSD':
             exec("xdg-open {$url}");
             break;
         default:
             $output->writeln("<error>Your operating system (" . PHP_OS . ") isn't supported for the open command.</error>", $this->app->outputFormat);
     }
 }
开发者ID:enobrev,项目名称:fogbugz-php-cli,代码行数:30,代码来源:OpenCommand.php

示例14: getValues

 /**
  * @param  OutputInterface $output
  * @param  DialogHelper    $dialog
  * @return array
  */
 public function getValues(OutputInterface $output, DialogHelper $dialog)
 {
     $default = $this->getDefault();
     $value = $dialog->ask($output, "<info>Package Name</info> ({$default}): ", $default);
     $parts = explode('/', $default);
     $owner = $parts[0];
     $title = isset($parts[1]) ? $parts[1] : $default;
     return ['package_name' => $value, 'package_owner' => $owner, 'package_title' => $title, 'package_classname' => $this->toCamelCase($title)];
 }
开发者ID:clippings,项目名称:composer-init,代码行数:14,代码来源:PackageNamePrompt.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     $recentCases = $this->app->getRecent();
     if ($case == null) {
         $strlen = 4;
         if (!empty($recentCases)) {
             $output->writeln("What case are you working on?", $this->app->outputFormat);
             foreach ($recentCases as $recent_case) {
                 $output->writeln(sprintf("  <info>[%s]</info> %s", $recent_case['id'], substr($recent_case['title'], 0, 75)), $this->app->outputFormat);
                 // this is just for display purposes below
                 $strlen = strlen($recent_case['id']);
             }
             $output->writeln("  <info>[" . str_repeat('#', $strlen) . "]</info> Or type any other case number to start work", $this->app->outputFormat);
         }
         while ($case == null) {
             $case = $dialog->ask($output, "Case number: ");
         }
     }
     try {
         // We'll go ahead and look it up, and if we find it, we'll
         // save it to recent. Then, we'll issue the command and catch
         // any problems with it and deal with it then.
         $bug = $this->app->fogbugz->search(array('q' => (int) $case, 'cols' => 'sTitle,sStatus,sLatestTextSummary'));
         $title = (string) $bug->cases->case->sTitle;
         $this->app->pushRecent($case, $title);
         $this->app->fogbugz->startWork(array('ixBug' => $case));
         $output->writeln(sprintf("Now working on [%d]\n  %s\n", $case, $title), $this->app->outputFormat);
     } catch (ApiError $e) {
         if ($e->getCode() == '7') {
             if ($e->getMessage() == 'Case ' . $case . ' has no estimate') {
                 $output->writeln(sprintf("<alert>Case %s has no estimate.</alert>", $case), $this->app->outputFormat);
                 // Delegate to the set estimate
                 $command = $this->getApplication()->find('estimate');
                 $arguments = array('command' => 'estimate', 'case' => $case);
                 $input = new ArrayInput($arguments);
                 $command->run($input, $output);
                 // Now come back to start the case.
                 // TODO: move this to call, so we aren't working the catch.
                 $title = (string) $bug->cases->case->sTitle;
                 $this->app->fogbugz->startWork(array('ixBug' => $case));
                 $output->writeln(sprintf("Now working on [%d]\n  %s\n", $case, $title), $this->app->outputFormat);
                 return;
             } elseif ($e->getMessage() == 'Closed') {
                 $output->writeln(sprintf("<fire>Sorry, Case %s is closed and may not " . "have a time interval added to it.</fire>", $case), $this->app->outputFormat);
             } else {
                 $output->writeln(sprintf("<error>%s</error>", $e->getMessage()), $this->app->outputFormat);
             }
         } else {
             $output->writeln(sprintf("<error>%s</error>", $e->getMessage()), $this->app->outputFormat);
         }
         exit(1);
     }
 }
开发者ID:enobrev,项目名称:fogbugz-php-cli,代码行数:56,代码来源:StartCommand.php


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