aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
diff options
context:
space:
mode:
authorNicolas Hart <contact@nclshart.net>2017-07-29 00:30:22 +0200
committerNicolas Hart <contact@nclshart.net>2017-07-29 11:09:02 +0200
commite1b33efb3dd7c9ebb4dcfb23a2ca5efbda0a05f6 (patch)
treecc4a14dca4b1d533671c45b871d441308cdee545 /src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
parent233eb91be4bd381ff48de0a15aff94415a3f2797 (diff)
downloadwallabag-e1b33efb3dd7c9ebb4dcfb23a2ca5efbda0a05f6.tar.gz
wallabag-e1b33efb3dd7c9ebb4dcfb23a2ca5efbda0a05f6.tar.zst
wallabag-e1b33efb3dd7c9ebb4dcfb23a2ca5efbda0a05f6.zip
Better rendering for all core commands
Diffstat (limited to 'src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php')
-rw-r--r--src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
index b4aa4e47..1caaa391 100644
--- a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
+++ b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
@@ -7,13 +7,14 @@ use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
7use Symfony\Component\Console\Input\InputArgument; 7use Symfony\Component\Console\Input\InputArgument;
8use Symfony\Component\Console\Input\InputInterface; 8use Symfony\Component\Console\Input\InputInterface;
9use Symfony\Component\Console\Output\OutputInterface; 9use Symfony\Component\Console\Output\OutputInterface;
10use Symfony\Component\Console\Style\SymfonyStyle;
10use Wallabag\CoreBundle\Entity\Entry; 11use Wallabag\CoreBundle\Entity\Entry;
11use Wallabag\UserBundle\Entity\User; 12use Wallabag\UserBundle\Entity\User;
12 13
13class CleanDuplicatesCommand extends ContainerAwareCommand 14class CleanDuplicatesCommand extends ContainerAwareCommand
14{ 15{
15 /** @var OutputInterface */ 16 /** @var SymfonyStyle */
16 protected $output; 17 protected $io;
17 18
18 protected $duplicates = 0; 19 protected $duplicates = 0;
19 20
@@ -32,7 +33,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
32 33
33 protected function execute(InputInterface $input, OutputInterface $output) 34 protected function execute(InputInterface $input, OutputInterface $output)
34 { 35 {
35 $this->output = $output; 36 $this->io = new SymfonyStyle($input, $output);
36 37
37 $username = $input->getArgument('username'); 38 $username = $input->getArgument('username');
38 39
@@ -41,20 +42,22 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
41 $user = $this->getUser($username); 42 $user = $this->getUser($username);
42 $this->cleanDuplicates($user); 43 $this->cleanDuplicates($user);
43 } catch (NoResultException $e) { 44 } catch (NoResultException $e) {
44 $output->writeln(sprintf('<error>User "%s" not found.</error>', $username)); 45 $this->io->error(sprintf('User "%s" not found.', $username));
45 46
46 return 1; 47 return 1;
47 } 48 }
49
50 $this->io->success('Finished cleaning.');
48 } else { 51 } else {
49 $users = $this->getContainer()->get('wallabag_user.user_repository')->findAll(); 52 $users = $this->getContainer()->get('wallabag_user.user_repository')->findAll();
50 53
51 $output->writeln(sprintf('Cleaning through %d user accounts', count($users))); 54 $this->io->text(sprintf('Cleaning through <info>%d</info> user accounts', count($users)));
52 55
53 foreach ($users as $user) { 56 foreach ($users as $user) {
54 $output->writeln(sprintf('Processing user %s', $user->getUsername())); 57 $this->io->text(sprintf('Processing user <info>%s</info>', $user->getUsername()));
55 $this->cleanDuplicates($user); 58 $this->cleanDuplicates($user);
56 } 59 }
57 $output->writeln(sprintf('Finished cleaning. %d duplicates found in total', $this->duplicates)); 60 $this->io->success(sprintf('Finished cleaning. %d duplicates found in total', $this->duplicates));
58 } 61 }
59 62
60 return 0; 63 return 0;
@@ -88,7 +91,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
88 91
89 $this->duplicates += $duplicatesCount; 92 $this->duplicates += $duplicatesCount;
90 93
91 $this->output->writeln(sprintf('Cleaned %d duplicates for user %s', $duplicatesCount, $user->getUserName())); 94 $this->io->text(sprintf('Cleaned <info>%d</info> duplicates for user <info>%s</info>', $duplicatesCount, $user->getUserName()));
92 } 95 }
93 96
94 private function similarUrl($url) 97 private function similarUrl($url)