예제 #1
0
 /**
  * Configures the interactive part of the console application
  * @param InputInterface $input The console input object
  * @param OutputInterface $output The console output object
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     if (empty($input->getArgument('issue-key'))) {
         $this->connect($input->getOption('url'), $input->getOption('auth'));
         $question = new Question('Issue key: ');
         $question->setAutocompleterValues(Project::getInstance()->getAllProjectKeys());
         $input->setArgument('issue-key', $this->getHelper('question')->ask($input, $output, $question));
     }
 }
예제 #2
0
 /**
  * Configures the interactive part of the console application
  * @param InputInterface $input The console input object
  * @param OutputInterface $output The console output object
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $hash = !empty($input->getOption('hash')) ? json_decode(base64_decode($input->getOption('hash'))) : '';
     if (empty($input->getArgument('project'))) {
         $this->connect($input->getOption('url'), $input->getOption('auth'));
         $question = new ChoiceQuestion('Project: ', Project::getInstance()->getAllProjectKeys(), !empty($hash->project) ? $hash->project : null);
         $question->setErrorMessage('Project %s is invalid');
         $input->setArgument('project', $helper->ask($input, $output, $question));
     }
     if (empty($input->getArgument('title'))) {
         $question = new Question('Title: ', !empty($hash->subject) ? $hash->subject : null);
         $input->setArgument('title', $helper->ask($input, $output, $question));
     }
     if (empty($input->getArgument('description'))) {
         $question = new Question('Description: ', !empty($hash->message) ? $hash->message : null);
         $input->setArgument('description', $helper->ask($input, $output, $question));
     }
     if (empty($input->getOption('priority'))) {
         $question = new ChoiceQuestion('Priority: ', $this->priorities, !empty($hash->priority) ? $hash->priority : 'Medium');
         $question->setErrorMessage('Priority %s is invalid');
         $input->setOption('priority', $helper->ask($input, $output, $question));
     }
     if (!empty($this->config['custom'])) {
         $this->availableConfig = Issue::getInstance()->getProjectIssueAvailableConfig($input->getArgument('project'));
         foreach ($this->config['custom'] as $name => $argument) {
             if (empty($this->availableConfig->projects[0]->issuetypes[0]->fields->{$name}->name)) {
                 continue;
             }
             switch ($argument['type']) {
                 case 'ChoiceQuestion':
                     $allowedValues = array();
                     $customField = $this->availableConfig->projects[0]->issuetypes[0]->fields->{$name};
                     foreach ($customField->allowedValues as $allowedValue) {
                         $allowedValues[$allowedValue->id] = $allowedValue->value;
                     }
                     $question = new ChoiceQuestion($customField->name . ': ', $allowedValues, !empty($hash->{$name}) ? $hash->{$name} : null);
                     $input->setArgument($name, $helper->ask($input, $output, $question));
                     break;
                 case 'Question':
                 default:
                     $question = new Question($this->availableConfig->projects[0]->issuetypes[0]->fields->{$name}->name . ': ', !empty($hash->{$name}) ? $hash->{$name} : null);
                     $input->setArgument($name, $helper->ask($input, $output, $question));
             }
         }
     }
 }