Imrove feedback

This commit is contained in:
Tim 2022-09-28 13:59:33 +02:00
parent 1888923d28
commit b68b4564df

View File

@ -45,6 +45,7 @@ abstract class AbstractEntityCommand extends Command
$this->getConfig($builder); $this->getConfig($builder);
if ($input->getOption('create')) { if ($input->getOption('create')) {
$io->info(sprintf('Creating new "%s"', $this->getEntityClass()));
$entity = new ($this->getEntityClass())(); $entity = new ($this->getEntityClass())();
$builder->setAll($entity); $builder->setAll($entity);
@ -52,9 +53,11 @@ abstract class AbstractEntityCommand extends Command
$io->success(sprintf('Object "%s" (id: %s) stored successfully', $entity, $entity->getId())); $io->success(sprintf('Object "%s" (id: %s) stored successfully', $entity, $entity->getId()));
} }
} elseif ($input->getOption('modify')) { } elseif ($input->getOption('modify')) {
$io->info(sprintf('Modifying "%s"', $this->getEntityClass()));
$entity = $this->select($io, $id); $entity = $this->select($io, $id);
$builder->setByQuestion($entity); $builder->setByQuestion($entity);
} elseif ($input->getOption('delete')) { } elseif ($input->getOption('delete')) {
$io->info(sprintf('Deleting "%s"', $this->getEntityClass()));
$entity = $this->select($io, $id); $entity = $this->select($io, $id);
if ($io->askQuestion(new ConfirmationQuestion(sprintf('Are you sure you want to delete %s', $entity)))) { if ($io->askQuestion(new ConfirmationQuestion(sprintf('Are you sure you want to delete %s', $entity)))) {
$name = (string)$entity; $name = (string)$entity;
@ -62,6 +65,7 @@ abstract class AbstractEntityCommand extends Command
$io->success(sprintf('Config "%s" deleted', $name)); $io->success(sprintf('Config "%s" deleted', $name));
} }
} elseif ($input->getOption('show')) { } elseif ($input->getOption('show')) {
$io->info(sprintf('Showing "%s"', $this->getEntityClass()));
$entity = $this->select($io, $id); $entity = $this->select($io, $id);
$table = $io->createTable(); $table = $io->createTable();
$table->setHeaders(['property', 'value']); $table->setHeaders(['property', 'value']);
@ -69,8 +73,8 @@ abstract class AbstractEntityCommand extends Command
$table->setHeaderTitle(sprintf('id: %s', $entity->getId())); $table->setHeaderTitle(sprintf('id: %s', $entity->getId()));
$table->render(); $table->render();
} else { } else {
$io->error('Select at least one of the options'); $io->error('Select at least one of the options: Create (-c), Modify (-m), Delete (-d) or Show (-s)');
return Command::FAILURE; return Command::INVALID;
} }
$this->em->persist($entity); $this->em->persist($entity);