Skip to content

Commit

Permalink
Show both project keys and labels of add command
Browse files Browse the repository at this point in the history
  • Loading branch information
marvil07-adapt committed Nov 23, 2023
1 parent 859d3eb commit c46a833
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Console/Command/AddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ class AddCommand extends Command {
*/
const UNDEFINED_PROJECT = 'New project';

/**
* Key for undefined project.
*
* @var string
*/
const UNDEFINED_PROJECT_KEY = 'new';

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -112,16 +119,18 @@ protected function getOrganization(InputInterface $input, OutputInterface $outpu
*/
protected function getProject(InputInterface $input, OutputInterface $output) {
$helper = $this->getHelper('question');
$projects = array_keys($this->contributions['projects']);
array_unshift($projects, self::UNDEFINED_PROJECT);
$projects = [self::UNDEFINED_PROJECT_KEY => self::UNDEFINED_PROJECT];
foreach ($this->contributions['projects'] as $project_key => $project) {
$projects[$project_key] = $project['name'];
}
$question = new ChoiceQuestion(
'[1/7] Which project received the contribution?',
$projects,
0
);
$question->setErrorMessage('Project %s is invalid.');
$project = $helper->ask($input, $output, $question);
if ($project == self::UNDEFINED_PROJECT) {
if ($project == self::UNDEFINED_PROJECT_KEY) {
$question = new Question('What is the machine name of the project? (E.g. drupal/migrate_plus): ');
$question->setValidator([self::class, 'isNotEmpty']);
$machine_name = $helper->ask($input, $output, $question);
Expand Down

0 comments on commit c46a833

Please sign in to comment.