Skip to content

Commit 688556a

Browse files
committed
add the new ProgressIndicator
1 parent 33ae8f2 commit 688556a

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

ux.symfony.com/src/Command/LoadDataCommand.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Doctrine\ORM\EntityManagerInterface;
2323
use Symfony\Component\Console\Attribute\AsCommand;
2424
use Symfony\Component\Console\Command\Command;
25+
use Symfony\Component\Console\Helper\ProgressIndicator;
2526
use Symfony\Component\Console\Input\InputInterface;
2627
use Symfony\Component\Console\Output\OutputInterface;
2728
use Symfony\Component\Console\Style\SymfonyStyle;
@@ -38,13 +39,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
3839
{
3940
$io = new SymfonyStyle($input, $output);
4041

41-
$this->clearEntity(Chat::class, $io);
42-
$this->clearEntity(TodoItem::class, $io);
43-
$this->clearEntity(TodoList::class, $io);
44-
$this->clearEntity(InvoiceItem::class, $io);
45-
$this->clearEntity(Invoice::class, $io);
46-
$this->growFood($io);
47-
$this->manufactureProducts($io);
42+
$progressIndicator = new ProgressIndicator($output, finishedIndicatorValue: '');
43+
try {
44+
$progressIndicator->start("Loading data");
45+
$this->clearEntity(Chat::class, $io);
46+
$this->clearEntity(TodoItem::class, $io);
47+
$this->clearEntity(TodoList::class, $io);
48+
$this->clearEntity(InvoiceItem::class, $io);
49+
$this->clearEntity(Invoice::class, $io);
50+
$this->growFood($io);
51+
$this->manufactureProducts($io);
52+
$progressIndicator->finish('Finished');
53+
} catch (\Exception) {
54+
$progressIndicator->finish('Failed', '🚨');
55+
}
4856

4957
return Command::SUCCESS;
5058
}

0 commit comments

Comments
 (0)