Skip to content

Commit

Permalink
status needs to be title not abbrevation over api
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Sep 29, 2017
1 parent 08d5e9c commit fd8620b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Command/CloseIssueCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
private function getStatus()
{
$status = $this->input->getOption('status');
if ($status) {
return $status;
}
$default = $this->input->getOption('status');

$list = $this->getClient()->getClosedAbbreviationAssocList($this->getProjectId());
$prompt = 'Which status do you want to use in this action?';
$errorMessage = "Entered status doesn't match any in the list available to you";

return $this->askChoices($prompt, $list, $errorMessage);
$answer = $this->askChoices($prompt, $list, $errorMessage, $default);

return $list[$answer];
}

/**
Expand Down Expand Up @@ -172,7 +171,7 @@ private function getMessage()
/**
* ask choices, but return the key not value from the list.
*/
private function askChoices($prompt, $list, $errorMessage)
private function askChoices($prompt, $list, $errorMessage, $default = null)
{
// avoid asking if answer is known
switch (count($list)) {
Expand All @@ -182,7 +181,11 @@ private function askChoices($prompt, $list, $errorMessage)
return key($list);
}

$answer = $this->io->askChoices($prompt, $list, $errorMessage);
if ($default) {
$prompt .= " ($default)";
}

$answer = $this->io->askChoices($prompt, $list, $errorMessage, $default);

return array_search($answer, $list);
}
Expand Down

0 comments on commit fd8620b

Please sign in to comment.