aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNicolas Hart <contact@nclshart.net>2017-07-27 23:25:27 +0200
committerNicolas Hart <contact@nclshart.net>2017-07-27 23:34:57 +0200
commitd58199f3624c1cca1f851b4af5b8c88dea613a3b (patch)
tree03eb420df4db0f436c8e91b6a9a636c840fb8258 /src
parentf39152ad6e62f1ea43f501e88a8839526d77ef6c (diff)
downloadwallabag-d58199f3624c1cca1f851b4af5b8c88dea613a3b.tar.gz
wallabag-d58199f3624c1cca1f851b4af5b8c88dea613a3b.tar.zst
wallabag-d58199f3624c1cca1f851b4af5b8c88dea613a3b.zip
Better rendering for show user command using symfony style
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Command/ShowUserCommand.php23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php
index eef04988..33888fa3 100644
--- a/src/Wallabag/CoreBundle/Command/ShowUserCommand.php
+++ b/src/Wallabag/CoreBundle/Command/ShowUserCommand.php
@@ -7,12 +7,13 @@ 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\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
11 12
12class ShowUserCommand extends ContainerAwareCommand 13class ShowUserCommand extends ContainerAwareCommand
13{ 14{
14 /** @var OutputInterface */ 15 /** @var SymfonyStyle */
15 protected $output; 16 protected $io;
16 17
17 protected function configure() 18 protected function configure()
18 { 19 {
@@ -29,7 +30,7 @@ class ShowUserCommand extends ContainerAwareCommand
29 30
30 protected function execute(InputInterface $input, OutputInterface $output) 31 protected function execute(InputInterface $input, OutputInterface $output)
31 { 32 {
32 $this->output = $output; 33 $this->io = new SymfonyStyle($input, $output);
33 34
34 $username = $input->getArgument('username'); 35 $username = $input->getArgument('username');
35 36
@@ -37,7 +38,7 @@ class ShowUserCommand extends ContainerAwareCommand
37 $user = $this->getUser($username); 38 $user = $this->getUser($username);
38 $this->showUser($user); 39 $this->showUser($user);
39 } catch (NoResultException $e) { 40 } catch (NoResultException $e) {
40 $output->writeln(sprintf('<error>User "%s" not found.</error>', $username)); 41 $this->io->error(sprintf('User "%s" not found.', $username));
41 42
42 return 1; 43 return 1;
43 } 44 }
@@ -50,12 +51,14 @@ class ShowUserCommand extends ContainerAwareCommand
50 */ 51 */
51 private function showUser(User $user) 52 private function showUser(User $user)
52 { 53 {
53 $this->output->writeln(sprintf('Username : %s', $user->getUsername())); 54 $this->io->listing([
54 $this->output->writeln(sprintf('Email : %s', $user->getEmail())); 55 sprintf('Username : %s', $user->getUsername()),
55 $this->output->writeln(sprintf('Display name : %s', $user->getName())); 56 sprintf('Email : %s', $user->getEmail()),
56 $this->output->writeln(sprintf('Creation date : %s', $user->getCreatedAt()->format('Y-m-d H:i:s'))); 57 sprintf('Display name : %s', $user->getName()),
57 $this->output->writeln(sprintf('Last login : %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never')); 58 sprintf('Creation date : %s', $user->getCreatedAt()->format('Y-m-d H:i:s')),
58 $this->output->writeln(sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no')); 59 sprintf('Last login : %s', $user->getLastLogin() !== null ? $user->getLastLogin()->format('Y-m-d H:i:s') : 'never'),
60 sprintf('2FA activated: %s', $user->isTwoFactorAuthentication() ? 'yes' : 'no'),
61 ]);
59 } 62 }
60 63
61 /** 64 /**