ask() public method

Asks a question to the user.
public ask ( Symfony\Component\Console\Output\OutputInterface $output, string | array $question, string $default = null ) : string
$output Symfony\Component\Console\Output\OutputInterface
$question string | array The question to ask
$default string The default answer if none is given by the user
return string The user answer
Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
 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.
 }
Exemplo n.º 3
0
 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()));
 }
Exemplo n.º 4
0
 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);
     }
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 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\n\tTest\n\nS\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));
 }
Exemplo n.º 8
0
 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;
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
 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();
 }
Exemplo n.º 11
0
 /**
  * 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;
 }
Exemplo n.º 12
0
 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: "******"   <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
 }
Exemplo n.º 13
0
 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);
     }
 }
Exemplo n.º 14
0
 /**
  * @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)];
 }
Exemplo n.º 15
0
 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);
     }
 }
Exemplo n.º 16
0
 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);
         }
     }
     $activePeople = $this->app->fogbugz->listPeople(array('fIncludeActive' => 1));
     $virtualPeople = $this->app->fogbugz->listPeople(array('fIncludeVirtual' => 1));
     $output->writeln('<alert>Active Users</alert>');
     $i = 1;
     $peopleMap = array();
     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);
             $peopleMap[(int) $person->ixPerson] = $person->sFullName;
         }
         $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('ixBug' => $case, 'ixPersonAssignedTo' => $assignedto, 'sEvent' => empty($note) ? '' : $note);
     try {
         $this->app->fogbugz->assign($request);
         printf("Assigned case %s to %s\n", $case, $peopleMap[$assignedto]);
     } catch (ApiError $e) {
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()), $this->app->outputFormat);
         exit(1);
     }
 }
Exemplo n.º 17
0
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $output->writeln('creating new admin...');
     $dm = $this->dm;
     $dialog = new Console\Helper\DialogHelper();
     $email = $input->getArgument('email');
     $password = $input->getArgument('password');
     if ($email === null) {
         $email = $dialog->ask($output, '<question>please provide email for the new user: </question>', null);
         if ($email === null) {
             $output->writeln('<error>you have to provide email. aborting.</error>');
             return;
         }
         $password = $dialog->ask($output, '<question>please provide password for the user ' . $email . ': </question>', null);
         if ($password === null) {
             $output->writeln('<error>you have to provide password. aborting.</error>');
             return;
         }
     }
     if ($email !== null and $password === null) {
         $password = $dialog->ask($output, '<question>please provide password for the user ' . $email . ': </question>', null);
         if ($password === null) {
             $output->writeln('<error>you have to provide password. aborting.</error>');
             return;
         }
     }
     if ($dm->getRepository('User')->findOneByLogin($email) !== null) {
         $output->writeln('<error>user with email ' . $email . ' already exists. aborting.</error>');
         return;
     }
     $admin = new \Admin();
     $hash = password_hash($password, PASSWORD_BCRYPT);
     $admin->setEmail('*****@*****.**')->setPassword($hash);
     $dm->persist($admin);
     //$dm->flush(array('safe' => true)); //throws some bullshit error, thus checking by finding by email
     try {
         $this->dm->flush($admin, array('safe' => true));
         $output->writeln('<info>admin succesfully created</info>');
     } catch (\MongoCursorException $e) {
         $output->writeln('<error>admin already exists</error>');
     }
 }
Exemplo n.º 18
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $case = $input->getArgument('case');
     $estimate = $input->getArgument('estimate');
     if ($case == null) {
         $case = $dialog->ask($output, "Please provide a case:");
     }
     if ($estimate == null) {
         $estimate = $dialog->ask($output, "Please enter an estimate for this case in hours: ");
     }
     try {
         $this->app->fogbugz->edit(array('ixBug' => $case, 'hrsCurrEst' => $estimate));
     } catch (ApiError $e) {
         $output->writeln(sprintf("<error>%s</error>", $e->getMessage()), $this->app->outputFormat);
         exit(1);
     }
     $output->writeln(sprintf("Set estimate on <info>Case %s</info> to <info>%s %s</info>.", $case, $estimate, $estimate == '1' ? 'hour' : 'hours'), $this->app->outputFormat);
 }
Exemplo n.º 19
0
Arquivo: Output.php Projeto: liip/rmt
 public function askConfirmation($text, InputInterface $input = null)
 {
     if ($this->dialogHelper instanceof QuestionHelper) {
         if (!$input) {
             throw new \InvalidArgumentException('With symfony 3, the input stream may not be null');
         }
         return $this->dialogHelper->ask($input, $this, new ConfirmationQuestion($text));
     }
     if ($this->dialogHelper instanceof DialogHelper) {
         return $this->dialogHelper->askConfirmation($this, $text);
     }
     throw new \RuntimeException("Invalid dialogHelper");
 }
Exemplo n.º 20
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $filter = $input->getArgument('filter');
     if (null === $filter) {
         $command = $this->getApplication()->find('filters');
         $arguments = array('command' => 'filters');
         $input = new ArrayInput($arguments);
         $command->run($input, $output);
         $filter = $dialog->ask($output, "Enter a filter number: ");
     }
     $this->app->fogbugz->setCurrentFilter(array('sFilter' => $filter));
     $output->writeln(sprintf("Set the current active filter to: %s", $filter), $this->app->outputFormat);
 }
Exemplo n.º 21
0
 /**
  * Interacts with the user.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $dialog = new DialogHelper();
     $answers = array();
     # Ask for the database type
     $answers['type'] = strtolower($dialog->ask($output, '<question>Which Database does this belong? [mysql|mssql|oracle|posgsql|oci8|sqlite]: </question>', 'mysql'));
     # apply format of the Doctrine DBAL
     $answers['type'] = $answers['type'] !== 'oci8' ? $answers['type'] = 'pdo_' . $answers['type'] : $answers['type'];
     # fetch interact from the Config/Driver/CLI
     $questions_driver = $this->getApplication()->getProject()->getConfigManager()->getCLIFactory()->create($answers['type']);
     $answers = $questions_driver->interact($dialog, $output, $answers);
     # Store answers for the execute method
     $this->answers = $answers;
     return true;
 }
 /**
  * @param Crawler $crawler
  */
 protected function getMethodDefinitions($crawler)
 {
     $methodDefinitions = $crawler->filter('#method-info > div');
     $this->output->writeln(sprintf("Found %d definitions:", $methodDefinitions->count()));
     foreach ($methodDefinitions as $definition) {
         $operationData = $this->parseOperationData($definition);
         $this->output->writeln(sprintf("<comment>%s</comment> <info>%s</info>", $operationData['httpMethod'], $operationData['uri']));
         $this->output->writeln(sprintf("<comment>Summary:</comment> <info>%s</info>", $operationData['summary']));
         $this->output->writeln(sprintf("<comment>Parameters:</comment> <info>%s</info>", implode(",", array_keys($operationData['parameters']))));
         $operation = $this->dialog->ask($this->output, "<question>How do you wish to name this Operation? [" . $operationData['operation'] . "]</question>", $operationData['operation']);
         unset($operationData['operation']);
         $apiType = $this->dialog->ask($this->output, "<question>Which API? [v2]</question>", 'v2', array_keys($this->apis));
         $this->apis[$apiType][$operation] = $operationData;
     }
 }
Exemplo n.º 23
0
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $output->writeln('creating new user...');
     $dialog = new Console\Helper\DialogHelper();
     $nick = $input->getArgument('nick');
     $email = $input->getArgument('email');
     $password = $input->getArgument('password');
     if ($nick === NULL) {
         $nick = $dialog->ask($output, '<question>please provide nick for the new user: </question>', NULL);
         if ($nick === NULL) {
             $output->writeln('<error>you have to provide nick. aborting.</error>');
             return;
         }
         $password = $dialog->ask($output, '<question>please provide password for the user ' . $nick . ': </question>', NULL);
         if ($password === NULL) {
             $output->writeln('<error>you have to provide password. aborting.</error>');
             return;
         }
     }
     if ($email === NULL) {
         $email = $dialog->ask($output, '<question>please provide email for the new user: </question>', NULL);
         if ($email === NULL) {
             $output->writeln('<error>you have to provide email. aborting.</error>');
             return;
         }
     }
     if ($nick !== NULL and $password === NULL) {
         $password = $dialog->ask($output, '<question>please provide password for the user ' . $nick . ': </question>', NULL);
         if ($password === NULL) {
             $output->writeln('<error>you have to provide password. aborting.</error>');
             return;
         }
     }
     $this->userFacade->createUser($nick, $email, $password);
     $output->writeln('<info>user ' . $nick . ' succesfully created</info>');
 }
Exemplo n.º 24
0
 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 {
         $this->app->fogbugz->reopen(array('ixBug' => $case));
     } catch (ApiError $e) {
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()), $this->app->outputFormat);
         exit(1);
     }
     $output->writeln(sprintf('Case %d has been reopened.', $case), $this->app->outputFormat);
 }
Exemplo n.º 25
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->app = $this->getApplication();
     $dialog = new DialogHelper();
     $keyword = $input->getArgument('term');
     if (null === $keyword) {
         $keyword = $dialog->ask($output, 'Enter a search string: ');
     }
     $xml = $this->app->fogbugz->search(array('q' => $keyword, 'cols' => 'ixBug,sStatus,sTitle,hrsCurrEst,sPersonAssignedTo'));
     $tplData = array('filterTitle' => "Search resultes for '{$keyword}'", 'cases' => array());
     foreach ($xml->cases->children() as $case) {
         // Colorize the search term in the title of the case
         $title = (string) $case->sTitle;
         $title = str_ireplace($keyword, sprintf('<fire>%s</fire>', strtoupper($keyword)), $title);
         $tplData['cases'][] = array('id' => (int) $case->ixBug, 'status' => (string) $case->sStatus, 'statusFormat' => $this->app->statusStyle((string) $case->sStatus), 'title' => $title, 'estimate' => (string) $case->hrsCurrEst, 'assigned' => (string) $case->sPersonAssignedTo);
     }
     $template = $this->app->twig->loadTemplate('cases.twig');
     $view = $template->render($tplData);
     $output->write($view, true, $this->app->outputFormat);
 }
Exemplo n.º 26
0
 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>');
     if ($dialog->askConfirmation($output, '<question>Using a unix socket? [y|n] :</question>', false)) {
         $answers['sock'] = $dialog->ask($output, '<question> Unix Socked path relative to project root? : </question>', false);
     } else {
         #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);
     }
     #Database port
     $answers['charset'] = $dialog->ask($output, '<question>Connect with different character set? [false] : </question>', false);
     return $answers;
 }
Exemplo n.º 27
0
 /**
  * @param OutputInterface $outStream
  * @param OutputInterface $output
  * @param string $query
  * @param bool $interactive
  */
 protected function writeQueryString(OutputInterface $outStream, OutputInterface $output, $query, $interactive)
 {
     if ($interactive) {
         $output->writeln(sprintf('<info>Query: %s</info>', $query));
         $keep = (int) $this->dialog->select($output, '<question>What do you want to do with this query?</question>', $this->queryOptions, self::QUERY_USE);
         if ($keep === self::QUERY_SKIP) {
             //do not write query to $outStream
             return;
         }
         if ($keep === self::QUERY_COMMENT) {
             $query = sprintf('/** %s */', $query);
         }
         if ($keep === self::QUERY_REWRITE) {
             $query = $this->dialog->ask($output, '<comment>Your replacement query (blank uses current query)</comment>', $query);
             $query = trim($query);
             if (substr($query, -1) === ';') {
                 $query = substr($query, 0, -1);
                 //remove trailing semi-colon, we're adding it later anyway
             }
         }
     }
     $outStream->writeln($query . ';' . PHP_EOL);
 }
 public function testNoInteraction()
 {
     $dialog = new DialogHelper();
     $input = new ArrayInput(array());
     $input->setInteractive(false);
     $dialog->setInput($input);
     $this->assertEquals('not yet', $dialog->ask($this->getOutputStream(), 'Do you have a job?', 'not yet'));
 }
Exemplo n.º 29
0
 private function selectDatabase(OutputInterface $output)
 {
     $this->dbName = $this->dialog->ask($output, '<question>What is your database name? [BungaWire]</question> ', 'BungaWire');
 }
 public function getValues(OutputInterface $output, DialogHelper $dialog)
 {
     $value = $dialog->ask($output, "<info>Encrypted Slack Notification code</info>: ");
     return ['slack_notification' => $value ? "  slack:\n    secure: {$value}\n" : null];
 }