aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-07-28 07:38:15 +0200
committerGitHub <noreply@github.com>2017-07-28 07:38:15 +0200
commit233eb91be4bd381ff48de0a15aff94415a3f2797 (patch)
treee0d3a5ebcad8efbe0939f31c4e7b620870302ac5
parente56f82142ac890c916b74700087424017bb2acf9 (diff)
parentd58199f3624c1cca1f851b4af5b8c88dea613a3b (diff)
downloadwallabag-233eb91be4bd381ff48de0a15aff94415a3f2797.tar.gz
wallabag-233eb91be4bd381ff48de0a15aff94415a3f2797.tar.zst
wallabag-233eb91be4bd381ff48de0a15aff94415a3f2797.zip
Merge pull request #3291 from nclsHart/show-user-io
Better rendering for show user command using symfony style
-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 4511c235..090309d9 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 /**