From ccd36557123e410b76a69b380418cc1ca51b3889 Mon Sep 17 00:00:00 2001 From: Fabian Arrotin Date: Sep 25 2018 14:20:57 +0000 Subject: Adding 'list-groups' function to pagure-admin --- diff --git a/pagure/cli/admin.py b/pagure/cli/admin.py index 2e394af..0fdb87a 100644 --- a/pagure/cli/admin.py +++ b/pagure/cli/admin.py @@ -320,6 +320,19 @@ def _parser_new_group(subparser): local_parser.set_defaults(func=do_new_group) +def _parser_list_groups(subparser): + """ Set up the CLI argument parser for the list-groups action. + + :arg subparser: an argparse subparser allowing to have action's specific + arguments + + """ + local_parser = subparser.add_parser( + "list-groups", help="Lists existing groups on this pagure instance" + ) + local_parser.set_defaults(func=do_list_groups) + + def _parser_block_user(subparser): """ Set up the CLI argument parser for the block-user action. @@ -416,6 +429,9 @@ def parse_arguments(args=None): # new-group _parser_new_group(subparser) + # list-groups + _parser_list_groups(subparser) + # block-user _parser_block_user(subparser) @@ -863,6 +879,21 @@ def do_new_group(args): print("Group `%s` created." % args.group_name) print(msg) +def do_list_groups(args): + """ Lists existing groups in this pagure instance. + + :arg args: the argparse object returned by ``parse_arguments()``. + + """ + + msg = pagure.lib.search_groups( + session=session, + ) + session.commit() + print("List of groups on this Pagure instance:" ) + for group in msg: + print(group) + def do_block_user(args): """ Block the specified user from all interactions with pagure until the