aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Command/ExportCommand.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Command/ExportCommand.php')
-rw-r--r--src/Wallabag/CoreBundle/Command/ExportCommand.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Command/ExportCommand.php b/src/Wallabag/CoreBundle/Command/ExportCommand.php
index 291926e4..b07087c8 100644
--- a/src/Wallabag/CoreBundle/Command/ExportCommand.php
+++ b/src/Wallabag/CoreBundle/Command/ExportCommand.php
@@ -7,6 +7,7 @@ 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;
10 11
11class ExportCommand extends ContainerAwareCommand 12class ExportCommand extends ContainerAwareCommand
12{ 13{
@@ -31,10 +32,12 @@ class ExportCommand extends ContainerAwareCommand
31 32
32 protected function execute(InputInterface $input, OutputInterface $output) 33 protected function execute(InputInterface $input, OutputInterface $output)
33 { 34 {
35 $io = new SymfonyStyle($input, $output);
36
34 try { 37 try {
35 $user = $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($input->getArgument('username')); 38 $user = $this->getContainer()->get('wallabag_user.user_repository')->findOneByUserName($input->getArgument('username'));
36 } catch (NoResultException $e) { 39 } catch (NoResultException $e) {
37 $output->writeln(sprintf('<error>User "%s" not found.</error>', $input->getArgument('username'))); 40 $io->error(sprintf('User "%s" not found.', $input->getArgument('username')));
38 41
39 return 1; 42 return 1;
40 } 43 }
@@ -44,7 +47,7 @@ class ExportCommand extends ContainerAwareCommand
44 ->getQuery() 47 ->getQuery()
45 ->getResult(); 48 ->getResult();
46 49
47 $output->write(sprintf('Exporting %d entrie(s) for user « <comment>%s</comment> »... ', count($entries), $user->getUserName())); 50 $io->text(sprintf('Exporting <info>%d</info> entrie(s) for user <info>%s</info>...', count($entries), $user->getUserName()));
48 51
49 $filePath = $input->getArgument('filepath'); 52 $filePath = $input->getArgument('filepath');
50 53
@@ -60,12 +63,12 @@ class ExportCommand extends ContainerAwareCommand
60 ->exportJsonData(); 63 ->exportJsonData();
61 file_put_contents($filePath, $data); 64 file_put_contents($filePath, $data);
62 } catch (\InvalidArgumentException $e) { 65 } catch (\InvalidArgumentException $e) {
63 $output->writeln(sprintf('<error>Error: "%s"</error>', $e->getMessage())); 66 $io->error(sprintf('Error: "%s"', $e->getMessage()));
64 67
65 return 1; 68 return 1;
66 } 69 }
67 70
68 $output->writeln('<info>Done.</info>'); 71 $io->success('Done.');
69 72
70 return 0; 73 return 0;
71 } 74 }