3 namespace Wallabag\CoreBundle\Command
;
5 use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
;
6 use Symfony\Component\Console\Input\InputArgument
;
7 use Symfony\Component\Console\Input\InputInterface
;
8 use Symfony\Component\Console\Input\InputOption
;
9 use Symfony\Component\Console\Output\OutputInterface
;
10 use Symfony\Component\Console\Style\SymfonyStyle
;
12 class ListUserCommand
extends ContainerAwareCommand
14 protected function configure()
17 ->setName('wallabag:user:list')
18 ->setDescription('List all users')
19 ->setHelp('This command list all existing users')
20 ->addArgument('search', InputArgument
::OPTIONAL
, 'Filter list by given search term')
21 ->addOption('limit', 'l', InputOption
::VALUE_REQUIRED
, 'Max number of displayed users', 100)
25 protected function execute(InputInterface
$input, OutputInterface
$output)
27 $io = new SymfonyStyle($input, $output);
29 $users = $this->getContainer()->get('wallabag_user.user_repository')
30 ->getQueryBuilderForSearch($input->getArgument('search'))
31 ->setMaxResults($input->getOption('limit'))
35 $nbUsers = $this->getContainer()->get('wallabag_user.user_repository')
39 foreach ($users as $user) {
43 $user->isEnabled() ? 'yes' : 'no',
44 $user->hasRole('ROLE_SUPER_ADMIN') || $user->hasRole('ROLE_ADMIN') ? 'yes' : 'no',
48 $io->table(['username', 'email', 'is enabled?', 'is admin?'], $rows);
52 '%s/%s%s user(s) displayed.',
55 null === $input->getArgument('search') ? '' : ' (filtered)'