| @@ 30-65 (lines=36) @@ | ||
| 27 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 28 | use Symfony\Component\Console\Input\InputArgument; |
|
| 29 | ||
| 30 | class ListGroups extends Base { |
|
| 31 | /** @var \OCP\IGroupManager */ |
|
| 32 | protected $groupManager; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param IGroupManager $groupManager |
|
| 36 | */ |
|
| 37 | public function __construct(IGroupManager $groupManager) { |
|
| 38 | parent::__construct(); |
|
| 39 | $this->groupManager = $groupManager; |
|
| 40 | } |
|
| 41 | ||
| 42 | protected function configure() { |
|
| 43 | parent::configure(); |
|
| 44 | ||
| 45 | $this |
|
| 46 | ->setName('group:list') |
|
| 47 | ->setDescription('list groups') |
|
| 48 | ->addArgument( |
|
| 49 | 'search-pattern', |
|
| 50 | InputArgument::OPTIONAL, |
|
| 51 | 'Restrict the list to groups whose name contains the string' |
|
| 52 | ) |
|
| 53 | ; |
|
| 54 | } |
|
| 55 | ||
| 56 | protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 57 | $groupNameSubString = $input->getArgument('search-pattern'); |
|
| 58 | $groups = $this->groupManager->search($groupNameSubString, null, null, 'management'); |
|
| 59 | $groups = array_map(function($group) { |
|
| 60 | /** @var IGroup $group */ |
|
| 61 | return $group->getGID(); |
|
| 62 | }, $groups); |
|
| 63 | parent::writeArrayInOutputFormat($input, $output, $groups); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| @@ 30-65 (lines=36) @@ | ||
| 27 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 28 | use Symfony\Component\Console\Input\InputArgument; |
|
| 29 | ||
| 30 | class ListUsers extends Base { |
|
| 31 | /** @var \OCP\IUserManager */ |
|
| 32 | protected $userManager; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param IUserManager $userManager |
|
| 36 | */ |
|
| 37 | public function __construct(IUserManager $userManager) { |
|
| 38 | parent::__construct(); |
|
| 39 | $this->userManager = $userManager; |
|
| 40 | } |
|
| 41 | ||
| 42 | protected function configure() { |
|
| 43 | parent::configure(); |
|
| 44 | ||
| 45 | $this |
|
| 46 | ->setName('user:list') |
|
| 47 | ->setDescription('list users') |
|
| 48 | ->addArgument( |
|
| 49 | 'search-pattern', |
|
| 50 | InputArgument::OPTIONAL, |
|
| 51 | 'Restrict the list to users whose User ID contains the string' |
|
| 52 | ) |
|
| 53 | ; |
|
| 54 | } |
|
| 55 | ||
| 56 | protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 57 | $userNameSubString = $input->getArgument('search-pattern'); |
|
| 58 | $users = $this->userManager->search($userNameSubString); |
|
| 59 | $users = array_map(function($user) { |
|
| 60 | /** @var IUser $user */ |
|
| 61 | return $user->getDisplayName(); |
|
| 62 | }, $users); |
|
| 63 | parent::writeArrayInOutputFormat($input, $output, $users); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||