diff options
author | Nicolas Hart <contact@nclshart.net> | 2017-07-29 00:30:22 +0200 |
---|---|---|
committer | Nicolas Hart <contact@nclshart.net> | 2017-07-29 11:09:02 +0200 |
commit | e1b33efb3dd7c9ebb4dcfb23a2ca5efbda0a05f6 (patch) | |
tree | cc4a14dca4b1d533671c45b871d441308cdee545 /src/Wallabag/CoreBundle/Command/ExportCommand.php | |
parent | 233eb91be4bd381ff48de0a15aff94415a3f2797 (diff) | |
download | wallabag-e1b33efb3dd7c9ebb4dcfb23a2ca5efbda0a05f6.tar.gz wallabag-e1b33efb3dd7c9ebb4dcfb23a2ca5efbda0a05f6.tar.zst wallabag-e1b33efb3dd7c9ebb4dcfb23a2ca5efbda0a05f6.zip |
Better rendering for all core commands
Diffstat (limited to 'src/Wallabag/CoreBundle/Command/ExportCommand.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Command/ExportCommand.php | 11 |
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; | |||
7 | use Symfony\Component\Console\Input\InputArgument; | 7 | use Symfony\Component\Console\Input\InputArgument; |
8 | use Symfony\Component\Console\Input\InputInterface; | 8 | use Symfony\Component\Console\Input\InputInterface; |
9 | use Symfony\Component\Console\Output\OutputInterface; | 9 | use Symfony\Component\Console\Output\OutputInterface; |
10 | use Symfony\Component\Console\Style\SymfonyStyle; | ||
10 | 11 | ||
11 | class ExportCommand extends ContainerAwareCommand | 12 | class 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 | } |