Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to provide a groupname and only see its' members in occ group:list #49016

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion core/Command/Group/ListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use OC\Core\Command\Base;
use OCP\IGroup;
use OCP\IGroupManager;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -23,6 +24,12 @@ protected function configure() {
$this
->setName('group:list')
->setDescription('list configured groups')
->addArgument(
'groupid',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'groupid',
'searchstring',

InputArgument::OPTIONAL,
'Group id to show only the members of that group',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Group id to show only the members of that group',
'Filter the groups to only those matching the search string',

''
)
->addOption(
'limit',
'l',
Expand Down Expand Up @@ -50,7 +57,7 @@ protected function configure() {
}

protected function execute(InputInterface $input, OutputInterface $output): int {
$groups = $this->groupManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset'));
$groups = $this->groupManager->search((string)$input->getArgument('groupid'), (int)$input->getOption('limit'), (int)$input->getOption('offset'));
Comment on lines -53 to +60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s not ideal, If there are groups abc and abc1 and you use group:list abc you will get both groups?

That said, maybe it’s actually better and we should just document the argument to be a search string and not a group name? Not sure.

I think we should document this as search string and merge it, and in an other PR add a --list-members option to group:info, that’s what make the most sense to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$groups = $this->groupManager->search((string)$input->getArgument('groupid'), (int)$input->getOption('limit'), (int)$input->getOption('offset'));
$groups = $this->groupManager->search((string)$input->getArgument('searchstring'), (int)$input->getOption('limit'), (int)$input->getOption('offset'));

$this->writeArrayInOutputFormat($input, $output, $this->formatGroups($groups, (bool)$input->getOption('info')));
return 0;
}
Expand Down